File tree Expand file tree Collapse file tree
Assets/Editor Toolbox/Editor Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
33
4+ // NOTE: Needed for EntityId
5+ #if UNITY_6000_4_OR_NEWER
6+ using UnityEngine ;
7+ #endif
8+
49namespace Toolbox . Editor
510{
611 using Editor = UnityEditor . Editor ;
712 using Object = UnityEngine . Object ;
813
914 public static class ToolboxEditorHandler
1015 {
16+ #if UNITY_6000_4_OR_NEWER
17+ private static EntityId lastCachedEditorId ;
18+ #else
1119 private static int lastCachedEditorId ;
20+ #endif
1221 private static Editor lastCachedEditor ;
1322 private static readonly Stack < Editor > cachedEditors = new Stack < Editor > ( ) ;
1423
1524 private static void OnBeginEditor ( Editor editor )
1625 {
1726 //NOTE: it means that last Editor was null or disposed, anyway we probably want to reload drawers-related cache
18- if ( lastCachedEditor == null || lastCachedEditorId != lastCachedEditor . GetInstanceID ( ) )
27+ #if UNITY_6000_4_OR_NEWER
28+ var lastId = lastCachedEditor . GetEntityId ( ) ;
29+ #else
30+ var lastId = lastCachedEditor . GetInstanceID ( ) ;
31+ #endif
32+ if ( lastCachedEditor == null || lastCachedEditorId != lastId )
1933 {
2034 lastCachedEditor = editor ;
35+ #if UNITY_6000_4_OR_NEWER
36+ lastCachedEditorId = editor . GetEntityId ( ) ;
37+ #else
2138 lastCachedEditorId = editor . GetInstanceID ( ) ;
39+ #endif
2240 OnEditorReload ? . Invoke ( ) ;
2341 }
2442
Original file line number Diff line number Diff line change @@ -26,8 +26,13 @@ internal enum LabelType
2626
2727 static ToolboxEditorHierarchy ( )
2828 {
29+ #if UNITY_6000_4_OR_NEWER
30+ EditorApplication . hierarchyWindowItemByEntityIdOnGUI -= OnItemCallback ;
31+ EditorApplication . hierarchyWindowItemByEntityIdOnGUI += OnItemCallback ;
32+ #else
2933 EditorApplication . hierarchyWindowItemOnGUI -= OnItemCallback ;
3034 EditorApplication . hierarchyWindowItemOnGUI += OnItemCallback ;
35+ #endif
3136 }
3237
3338 /// <summary>
@@ -38,7 +43,11 @@ static ToolboxEditorHierarchy()
3843 /// <summary>
3944 /// Tries to display item label in the Hierarchy Window.
4045 /// </summary>
46+ #if UNITY_6000_4_OR_NEWER
47+ private static void OnItemCallback ( EntityId instanceId , Rect rect )
48+ #else
4149 private static void OnItemCallback ( int instanceId , Rect rect )
50+ #endif
4251 {
4352 if ( ! IsOverlayAllowed )
4453 {
You can’t perform that action at this time.
0 commit comments