diff --git a/Assets/Fungus/Flowchart/Editor/BlockInspector.cs b/Assets/Fungus/Flowchart/Editor/BlockInspector.cs index 0f1f180f..99d7b53e 100644 --- a/Assets/Fungus/Flowchart/Editor/BlockInspector.cs +++ b/Assets/Fungus/Flowchart/Editor/BlockInspector.cs @@ -36,12 +36,29 @@ namespace Fungus // Cached command editors to avoid creating / destroying editors more than necessary protected Dictionary cachedCommandEditors = new Dictionary(); + protected void OnDestroy() + { + ClearEditors(); + } + + protected void OnEnable() + { + ClearEditors(); + } + protected void OnDisable() + { + ClearEditors(); + } + + protected void ClearEditors() { foreach (CommandEditor commandEditor in cachedCommandEditors.Values) { DestroyImmediate(commandEditor); } + cachedCommandEditors.Clear(); + activeCommandEditor = null; } public override void OnInspectorGUI ()