Hello everyone,
I have been working on building my own Node Graph Editor extension for Unity for the past few months, and I have come across a bug that I simply can’t seem to figure out. This is the first time I have actually become frustrated enough to reach out to the community for help with a problem since, in most cases, I have found my answers using the Search box or some good 'ol trial-and-error.
In almost every use-case it seems like my extension is perfectly functional, but I have found a single case that is causing me some major headaches. If I close the Unity IDE while my EditorWindow is opened and if I have a Node Graph loaded into the window, I find that the next time I run Unity the GUISkin that I have attached to my Editor asset has been destroyed. The GUISkin is being saved as a sub-asset to the main Editor asset, and when I select the GUISkin in the Hierarchy the Inspector remains completely blank. I am also seeing the following error message in the Console:
"MissingReferenceException: The object of type 'GUISkin' 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."
My EditorWindow class and the 3 “Panel” classes it stores a reference to each are marked as Serializable, and each of the Panel classes holds a reference to the main .asset file. When I reload Unity, each of the panel classes maintains the reference to the main .asset, but the GUISkin that the main .asset references has been destroyed. The .asset class derives from ScriptableObject.
If I close the Node Graph before I exit Unity, I do not have this issue, nor do I seem to have any issue entering or exiting Play Mode within Unity. I know that without posting specific code it may be a bit hard to point me in the right direction, but any advice would be greatly appreciated. At no point in my code do I explicitly destroy the GUISkin object (well, not unless I destroy the main .asset file), and I am at a complete loss as to how to prevent this issue.
Many thanks in advance