Builds differ from editor

I've got a strange issue with unity. I know similar topics have been posted, but I've scoured the forums, answers, and the unity web page for an answer without success.

Everything works properly in the editor... but for some reason I can't get the following code to work in standalone or web:

var spinnerBox = GameObject.FindWithTag("spinnerBox");
spinnerBox.transform.Rotate(0, 10, 0);

This script is applied to a game object with one child, designated "spinnerBox" as its tag. In the editor, it spins, in standalone, it does nothing. I've also tried to use:

var spinnerTrans = transform.Find("<object name>");
spinnerTrans.Rotate(0, 10, 0);

...which has the exact same effect.

I'm very impressed with unity's feature set so far and I'd really love to continue developing with it, but this issue is killing me. Thanks for any help in advance!


If this is in Update, then you want


spinnerBox.transform.Rotate(0.0, 10.0 * Time.deltaTime, 0.0);

because otherwise it's framerate-dependent. Although it would be better to do


spinnerBox.transform.Rotate(0.0, spinSpeed * Time.deltaTime, 0.0);

and set up the appropriate variable, so you can easily change the speed.

The main difference that shows up between builds and the editor is the order in which scripts are executed.

I would check very carefully that your awake and start calls are executing in the order you think they should. If indeed it is exactly what you've posted above that isn't working, I don't see anything wrong.

Have you looked in the output log when running the game? Except indeed what Eric5h5 says I can't see anything wrong directly but it's hard to say much from two lines of code. If the spinnerbox can't be found, there should have been an exception and this is written in the output log.

If the code is from the update function, it's quite expensive to do a find every update. Better make a global variable and do the find part in the Start function or instead of a find.

I'm having the exact same problem.

I posted it here:

It seems that my build code will not work with any new .js scripts I create. Once I've copied an pasted in tutorials work fine. Anything I do in the editor also works in the editor (but exclusively in the editor) this is not limited to transformations but to sounds, destroying objects etc.

Does anyone have an answer to what's going on?