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
- 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)
23
27
  {
24
- var obj = EditorUtility.EntityIdToObject(entityId) as GameObject;
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
- var obj = Resources.InstanceIDToObject( instanceId ) as GameObject;
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
- 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 );
46
54
 
47
55
  bool previousValue = obj.activeSelf;
48
56
 
49
- bool newValue = GUI.Toggle( rect, previousValue, GUIContent.none );
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, $"Set Active {obj.name}" );
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
  }
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.6",
4
+ "version" : "1.1.7",
5
5
  "author" : "Soosvet Games",
6
6
  "description" : "Common tools for Unity.",
7
7
  "repository": {