My C# editor class (the target script) declares a public GameObject, which is instantiated in the initial Reset() function via:
folder = new GameObject("My Folder");
But after going in to Play mode and stopping again, folder now has a null reference. It (and its contents) are still in the Hierarchy, but I can’t access them without a reference.
I’m quite new to C#, coming from C++, so I’m still a bit fuzzy on allocation and persistence.
Is the problem because the script is [ExecuteInEditMode] ?
What do I need to do to keep a reference to ‘folder’?
Thanks
AFAIK editor scripts aren't executed in edit mode. If you need an update then just attach a delegate to the EditorApplication.update callback. There are others as well and a list of them is [here][1]. [1]: http://docs.unity3d.com/Documentation/ScriptReference/EditorApplication.html
– iwaldrop