com.soosvet_games.common_tools 1.0.9 → 1.1.0

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.
@@ -6,32 +6,53 @@ namespace SoosvetGames.CommonTools.Extensions.Editor
6
6
  [ InitializeOnLoad ]
7
7
  internal static class HierarchyActivationTool
8
8
  {
9
- static HierarchyActivationTool() => EditorApplication.hierarchyWindowItemOnGUI += HierarchWindowOnGui;
9
+ static HierarchyActivationTool()
10
+ {
11
+ #if UNITY_6000_3_OR_NEWER
12
+ EditorApplication.hierarchyWindowItemByEntityIdOnGUI += HierarchyWindowOnGui;
13
+ #else
14
+ EditorApplication.hierarchyWindowItemOnGUI += HierarchyWindowOnGui;
15
+ #endif
16
+ }
17
+
18
+ #if UNITY_6000_3_OR_NEWER
19
+
20
+ private static void HierarchyWindowOnGui(EntityId entityId, Rect selectionRect)
21
+ {
22
+ var obj = EditorUtility.EntityIdToObject(entityId) as GameObject;
10
23
 
11
- private static void HierarchWindowOnGui( int instanceID, Rect selectionRect )
24
+ DrawToggle(obj, selectionRect);
25
+ }
26
+
27
+ #else
28
+
29
+ private static void HierarchyWindowOnGui( int instanceId, Rect selectionRect )
12
30
  {
13
- // make rectangle
14
- var r = new Rect(selectionRect);
15
- r.x = 35;
16
- r.width = 18;
17
-
18
- // get objects
19
- Object o = EditorUtility.InstanceIDToObject(instanceID);
20
- var obj = o as GameObject;
21
-
22
- // drag toggle gui
23
- if (obj != null)
24
- {
25
- bool prev = obj.activeSelf;
26
- bool next = GUI.Toggle(r, obj.activeSelf, string.Empty);
27
-
28
- if (next != prev)
29
- {
30
- Undo.RecordObject(obj, $"Record {obj.name}");
31
- obj.SetActive(next);
32
- EditorUtility.SetDirty(obj);
33
- }
34
- }
31
+ var obj = EditorUtility.InstanceIDToObject( instanceId ) as GameObject;
32
+
33
+ DrawToggle( obj, selectionRect );
34
+ }
35
+
36
+ #endif
37
+
38
+ private static void DrawToggle( GameObject obj, Rect selectionRect )
39
+ {
40
+ if ( obj == null )
41
+ return;
42
+
43
+ var rect = new Rect( selectionRect ) { x = 35, width = 18 };
44
+
45
+ bool previousValue = obj.activeSelf;
46
+ bool newValue = GUI.Toggle( rect, previousValue, string.Empty );
47
+
48
+ if ( newValue == previousValue )
49
+ return;
50
+
51
+ Undo.RecordObject( obj, $"Set Active {obj.name}" );
52
+
53
+ obj.SetActive( newValue );
54
+
55
+ EditorUtility.SetDirty( obj );
35
56
  }
36
57
  }
37
58
  }
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.0.9",
4
+ "version" : "1.1.0",
5
5
  "author" : "Soosvet Games",
6
6
  "description" : "Common tools for Unity.",
7
7
  "repository": {