- Home /
Script runs in editor, on its own
So I wrote a script (attached to a gameobject) that uses Start() to call the Constructor of a non-monobehaviour script, which in turn instantiates a few other gameobjects. I click 'play', the scripts execute and those gameobjects get spawned.
So far, so normal. Up to a certain point it worked fine, but at some time - it might have coincided with the update to the latest Unity version - those scripts started running in the editor rather than when pressing 'play'. This is not at all desirable to me.
I don't know why they do this, none of my scripts have ever done so before, and I just want them to stop running on their own without my explicit orders to do so.
Can anyone point me at the culprit?
Thanks in advance.
You sure you are not using [ExecuteInEdit$$anonymous$$ode]?
Absolutely certain. I didn't even know such a thing existed. Also checked all my scripts just now, and I didn't include it anywhere by accident either.
Without the code itself it is hard to pinpoint what is causing this.
$$anonymous$$aybe you created an editor script? (which will always run in edit mode).
With Javascript it would have @CustomEditor
I've gotten it to stop doing it. Apparently, having a public pointer in a monobehaviour class attached to a gameobject, which points to a non-monobehaviour class, automatically calls that class' constructor, even in the editor. Weird sh!t.
I'm still curious about this - my classes had no special tags at all apart from [System.Serializable], so I really don't know what would've caused it.