Seneral / Node_Editor_Framework

A flexible and modular Node Editor Framework for creating node based displays and editors in Unity
https://nodeeditor.seneral.dev
MIT License
2.01k stars 414 forks source link

Can´t load a canvas file after exiting Play mode #18

Closed pmhpereira closed 8 years ago

pmhpereira commented 8 years ago

When loading a canvas file after exiting Play mode, nothing appears in the Node Editor and a error is thrown. It also becomes impossible to add new nodes to the canvas. The solution is to start and stop the Play mode.

Steps to reproduce:

  1. Start Play mode in Unity
  2. Press New Canvas in the Node Editor
  3. Exit Playmode
  4. Load Canvas file

MissingReferenceException: The object of type 'Texture2D' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. NodeEditorFramework.NodeKnob.GetGUIKnob () (at Assets/Plugins/Node_Editor/Framework/NodeKnob.cs:143)

Seneral commented 8 years ago

To fix that, add these lines somewhere in NodeEditor.checkInit inside the if block:

#if UNITY_EDITOR
                UnityEditor.EditorApplication.playmodeStateChanged += () => { initiated = false; InitiationError = false; };
#endif

That simply makes sure the NodeEditor is re-inited after entering and editing playmode:)