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

Error occurs when I stop the Unity playmode. #65

Closed unagiHuman closed 8 years ago

unagiHuman commented 8 years ago

When I open the NodeEditor, and change the Unity playmode to stopped state, error occurs that Knob texture can not be loaded. In the source code, In EditorApplication.playmodeStateChanged, Node Editor trying to LoadCache at the timing to stop the application, but seemed to have failed in an attempt to load the Knob texture in UnityEditor.AssetDatabase.LoadAssetAtPath.

Seneral commented 8 years ago

Thanks, I hope to find time to take a look at this. It's very hard working with playmode compability in Unity due to the lack of callbacks and general information:(

unagiHuman commented 8 years ago

I debug the above bug and I found the cause of bug. Although Texture of memory is released when I stop the playmode of UnityEditor, null InKnobTex and OutKnobTex in TypeData is referenced by ReloadTexture() in NodeKnob class.

The reason for the memory of non-KnobTexture has not been released, Texuture except KnobTexture's is static variable.

Bug of the solution's two ways of following. 1.KnobTexture change static variable

  1. If KnobTexture is if null, so as to Reload in the property in the variable.
Seneral commented 8 years ago

Maybe I'll find ways (not in the soon future though:( ) to get more callacks out of Unity which will hopefully help with this. For now it might be a good idea to try one of the callbacks in EditorLoadingControl (like the cache system) in NodeEditorWindow and calling NodeEditor.ReInit in one of them;)

gregoiredelzongle commented 8 years ago

I had the same issue, I fixed it by calling TypeData.FetchTypes() if the texture cannot be found, which is a little bit hacky I agree

Seneral commented 8 years ago

May seem hacky, the cause is simply that the playmode switch seems to erase the data. So a different, maybe less hacky way would be to completely reinit the Node Editor in one of the callbacks in EditorLoadingControls, which the cache system are using. I won't check that out though because I cannot work on the project until next week:(

Seneral commented 8 years ago

Btw this has been fixed in cc44390!