Skip to content

Commit 9cf6f90

Browse files
committed
Fix NRE when checking lastCachedEditor in the ToolboxEditorHandler
1 parent 8eb3f8c commit 9cf6f90

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

Assets/Editor Toolbox/Editor/ToolboxEditorHandler.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
43
// NOTE: Needed for EntityId
54
#if UNITY_6000_4_OR_NEWER
65
using UnityEngine;
@@ -23,12 +22,12 @@ public static class ToolboxEditorHandler
2322

2423
private static void OnBeginEditor(Editor editor)
2524
{
26-
//NOTE: it means that last Editor was null or disposed, anyway we probably want to reload drawers-related cache
2725
#if UNITY_6000_4_OR_NEWER
28-
var lastId = lastCachedEditor.GetEntityId();
26+
var lastId = lastCachedEditor != null ? lastCachedEditor.GetEntityId() : default;
2927
#else
30-
var lastId = lastCachedEditor.GetInstanceID();
28+
var lastId = lastCachedEditor != null ? lastCachedEditor.GetInstanceID() : default;
3129
#endif
30+
//NOTE: it means that last Editor was null or disposed, anyway we probably want to reload drawers-related cache
3231
if (lastCachedEditor == null || lastCachedEditorId != lastId)
3332
{
3433
lastCachedEditor = editor;

0 commit comments

Comments
 (0)