Skip to content

Commit 8eb3f8c

Browse files
authored
Merge pull request #152 from nnra6864/6.5-fixes
6.5 Fixes
2 parents 18ac973 + b479ab8 commit 8eb3f8c

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

Assets/Editor Toolbox/Editor/ToolboxEditorHandler.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,42 @@
11
using System;
22
using System.Collections.Generic;
33

4+
// NOTE: Needed for EntityId
5+
#if UNITY_6000_4_OR_NEWER
6+
using UnityEngine;
7+
#endif
8+
49
namespace 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

Assets/Editor Toolbox/Editor/ToolboxEditorHierarchy.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff 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
{

0 commit comments

Comments
 (0)