Ilya
1
I have a editor script and I want it to run only while in the editor. It's not supposed to run while playing the game.
How can I prevent this?
I've added the following to the beginning of my script:
@script ExecuteInEditMode()
However Update is still being called inside the game.
system
2
You could preface the code in Update() with an ifcheck for Application.isEditor, or if you don't even want it to happen when it's playing in the editor, use Application.isPlaying.
yoyo
3
Checking for Application.isEditor works well. If you want the code to go away entirely in your final build you can (in C#, sorry not javascript) get the compiler to remove it, like so:
#if UNITY_EDITOR
void Update()
{
...
}
#endif
See the Unity docs for more info on conditional compilation.