I create a gameobject in a script’s start function, the script has ExecuteInEditMode.
i hit play… works great, hit play again to re-enter edit mode, and that same gameobject is created again… why?
I create a gameobject in a script’s start function, the script has ExecuteInEditMode.
i hit play… works great, hit play again to re-enter edit mode, and that same gameobject is created again… why?
because the start function is called whenever you “Start”. This includes, when [ExecuteInEditMode] is used, you start edit mode.
i see,
so then i would want to create the gameobject in awake?
That’s going to do the same thing. You’ll have to clean up the newly created game object in the script.
This makes 0 sense to me, since the documentation claims that awake and start are called when the behavior is loaded for the first time and once during the lifetime of the behavior!
so what you are telling me "because the start function is called whenever you “Start”. This includes, when [ExecuteInEditMode] is used, you start edit mode. " conflicts with what the documentation is saying.
the very way that the editor works is that some behaviors maintain their lifetime and state before, during, and after play.
Well in that case you have no issue.
thats not a very helpful response. i just dont understand how some objects are recreated after re-entering edit mode and some are not.
thanks to google i was able find loads of other people running into the same problem as me.
http://forum.unity3d.com/threads/107831-EditorWindow-loses-reference-of-ScriptableObject-on-Play-mode
http://forum.unity3d.com/threads/85597-Keep-inspector-values-set-during-game-play.
kind of disheartening since it appears 2 of these guys gave up.
found some things i can try though.