com.soosvet_games.common_tools 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19,18 +19,24 @@ namespace SoosvetGames.CommonTools.Extensions.Editor
|
|
|
19
19
|
|
|
20
20
|
#if UNITY_6000_5_OR_NEWER
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
// Unity 6000.5+
|
|
23
|
+
// ВАЖНО: здесь EntityId, никаких int / InstanceID.
|
|
24
|
+
private static void HierarchyWindowOnGui(
|
|
25
|
+
EntityId entityId,
|
|
26
|
+
Rect selectionRect)
|
|
23
27
|
{
|
|
24
|
-
|
|
28
|
+
GameObject obj =
|
|
29
|
+
EditorUtility.EntityIdToObject(entityId) as GameObject;
|
|
25
30
|
|
|
26
31
|
DrawToggle(obj, selectionRect);
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
#else
|
|
30
35
|
|
|
36
|
+
// Старые версии Unity
|
|
31
37
|
private static void HierarchyWindowOnGui( int instanceId, Rect selectionRect )
|
|
32
38
|
{
|
|
33
|
-
|
|
39
|
+
GameObject obj = EditorUtility.InstanceIDToObject( instanceId ) as GameObject;
|
|
34
40
|
|
|
35
41
|
DrawToggle( obj, selectionRect );
|
|
36
42
|
}
|
|
@@ -42,21 +48,21 @@ namespace SoosvetGames.CommonTools.Extensions.Editor
|
|
|
42
48
|
if ( obj == null )
|
|
43
49
|
return;
|
|
44
50
|
|
|
45
|
-
|
|
51
|
+
// Располагаем toggle относительно объекта,
|
|
52
|
+
// а не по абсолютному x = 35.
|
|
53
|
+
Rect toggleRect = new Rect( selectionRect.x - 18f, selectionRect.y, 16f, selectionRect.height );
|
|
46
54
|
|
|
47
55
|
bool previousValue = obj.activeSelf;
|
|
48
56
|
|
|
49
|
-
bool newValue = GUI.Toggle(
|
|
57
|
+
bool newValue = GUI.Toggle( toggleRect, previousValue, GUIContent.none );
|
|
50
58
|
|
|
51
59
|
if ( newValue == previousValue )
|
|
52
60
|
return;
|
|
53
61
|
|
|
54
|
-
Undo.RecordObject( obj, $"
|
|
62
|
+
Undo.RecordObject( obj, newValue ? $"Activate {obj.name}" : $"Deactivate {obj.name}" );
|
|
55
63
|
|
|
56
64
|
obj.SetActive( newValue );
|
|
57
65
|
|
|
58
|
-
EditorUtility.SetDirty( obj );
|
|
59
|
-
|
|
60
66
|
EditorApplication.RepaintHierarchyWindow();
|
|
61
67
|
}
|
|
62
68
|
}
|