Browse Source

Fix for intermittent error message in command editor OnEnable

master
chrisgregan 9 years ago
parent
commit
e0e1fbf4ae
  1. 17
      Assets/Fungus/Flowchart/Editor/BlockInspector.cs

17
Assets/Fungus/Flowchart/Editor/BlockInspector.cs

@ -36,12 +36,29 @@ namespace Fungus
// Cached command editors to avoid creating / destroying editors more than necessary // Cached command editors to avoid creating / destroying editors more than necessary
protected Dictionary<Command, CommandEditor> cachedCommandEditors = new Dictionary<Command, CommandEditor>(); protected Dictionary<Command, CommandEditor> cachedCommandEditors = new Dictionary<Command, CommandEditor>();
protected void OnDestroy()
{
ClearEditors();
}
protected void OnEnable()
{
ClearEditors();
}
protected void OnDisable() protected void OnDisable()
{
ClearEditors();
}
protected void ClearEditors()
{ {
foreach (CommandEditor commandEditor in cachedCommandEditors.Values) foreach (CommandEditor commandEditor in cachedCommandEditors.Values)
{ {
DestroyImmediate(commandEditor); DestroyImmediate(commandEditor);
} }
cachedCommandEditors.Clear();
activeCommandEditor = null;
} }
public override void OnInspectorGUI () public override void OnInspectorGUI ()

Loading…
Cancel
Save