com.soosvet_games.common_tools 1.1.5 → 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.
@@ -9,26 +9,34 @@ namespace SoosvetGames.CommonTools.Extensions.Editor
9
9
  static HierarchyActivationTool()
10
10
  {
11
11
  #if UNITY_6000_5_OR_NEWER
12
+ EditorApplication.hierarchyWindowItemByEntityIdOnGUI -= HierarchyWindowOnGui;
12
13
  EditorApplication.hierarchyWindowItemByEntityIdOnGUI += HierarchyWindowOnGui;
13
14
  #else
15
+ EditorApplication.hierarchyWindowItemOnGUI -= HierarchyWindowOnGui;
14
16
  EditorApplication.hierarchyWindowItemOnGUI += HierarchyWindowOnGui;
15
17
  #endif
16
18
  }
17
19
 
18
20
  #if UNITY_6000_5_OR_NEWER
19
21
 
20
- private static void HierarchyWindowOnGui( EntityId entityId,Rect selectionRect )
22
+ // Unity 6000.5+
23
+ // ВАЖНО: здесь EntityId, никаких int / InstanceID.
24
+ private static void HierarchyWindowOnGui(
25
+ EntityId entityId,
26
+ Rect selectionRect)
21
27
  {
22
- var obj = EditorUtility.EntityIdToObject(entityId) as GameObject;
28
+ GameObject obj =
29
+ EditorUtility.EntityIdToObject(entityId) as GameObject;
23
30
 
24
31
  DrawToggle(obj, selectionRect);
25
32
  }
26
33
 
27
34
  #else
28
35
 
36
+ // Старые версии Unity
29
37
  private static void HierarchyWindowOnGui( int instanceId, Rect selectionRect )
30
38
  {
31
- var obj = EditorUtility.InstanceIDToObject( instanceId ) as GameObject;
39
+ GameObject obj = EditorUtility.InstanceIDToObject( instanceId ) as GameObject;
32
40
 
33
41
  DrawToggle( obj, selectionRect );
34
42
  }
@@ -40,19 +48,22 @@ namespace SoosvetGames.CommonTools.Extensions.Editor
40
48
  if ( obj == null )
41
49
  return;
42
50
 
43
- var rect = new Rect( selectionRect ) { x = 35, width = 18 };
51
+ // Располагаем toggle относительно объекта,
52
+ // а не по абсолютному x = 35.
53
+ Rect toggleRect = new Rect( selectionRect.x - 18f, selectionRect.y, 16f, selectionRect.height );
44
54
 
45
55
  bool previousValue = obj.activeSelf;
46
- bool newValue = GUI.Toggle( rect, previousValue, string.Empty );
56
+
57
+ bool newValue = GUI.Toggle( toggleRect, previousValue, GUIContent.none );
47
58
 
48
59
  if ( newValue == previousValue )
49
60
  return;
50
61
 
51
- Undo.RecordObject( obj, $"Set Active {obj.name}" );
62
+ Undo.RecordObject( obj, newValue ? $"Activate {obj.name}" : $"Deactivate {obj.name}" );
52
63
 
53
64
  obj.SetActive( newValue );
54
65
 
55
- EditorUtility.SetDirty( obj );
66
+ EditorApplication.RepaintHierarchyWindow();
56
67
  }
57
68
  }
58
69
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name" : "com.soosvet_games.common_tools",
3
3
  "displayName" : "Soosvet Games Common Tools",
4
- "version" : "1.1.5",
4
+ "version" : "1.1.7",
5
5
  "author" : "Soosvet Games",
6
6
  "description" : "Common tools for Unity.",
7
7
  "repository": {