- Home /
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!
-Andrew
Answer by Eric5h5 · Jan 29, 2010 at 05:38 AM
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.
Yes, I am aware of this. The issue isn't how the script behaves, it's that it behaves completely differently in different builds (and nothing to do with time).
Answer by Horsman · Jan 29, 2010 at 01:38 PM
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.
I'm not using any Start() or Awake() functions at all, so that can't be the issue.
I was playing with it today, and discovered that a rotate script I created earlier does work (in both the editor and the web player). So I duplicated the script into a new JS file and applied it to the SA$$anonymous$$E object (after removing the previous script from it), and it no longer works in the web player (but still works in the engine). Words cannot describe my frustration.
Sounds frustrating indeed, but have you tried adding some debug statements and look in the output log? Do you have the same problem when you make a standalone build ins$$anonymous$$d of a web build?
I already posted that I checked the logs and there are no errors. When I build a standalone, there are $$anonymous$$ORE weird issues, but mostly with ti$$anonymous$$g (and yes, I know how to properly implement time with delta). I'm pretty sure this isn't an improperly implemented script... I reiterate that the SA$$anonymous$$E script works, but when duplicated into a new .js file and applied to the same object, it doesn't.
Answer by Jaap Kreijkamp · Jan 29, 2010 at 06:07 AM
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.
Thank you, but again, I'm aware of these things. I'm trying to keep it as simple as possible to be clear where the problem lies.
Either the Find() or the FindWithTag() function (or both) are not functioning in web or standalone releases, but appear to work just fine in the editor. I don't have any errors in my logs. Any idea why this could be?
Answer by Anthony Paul · Jun 19, 2010 at 12:51 AM
I'm having the exact same problem.
I posted it here: http://forum.unity3d.com/viewtopic.php?t=55264
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?
Your answer
![](https://koobas.hobune.stream/wayback/20220612040831im_/https://answers.unity.com/themes/thub/images/avi.jpg)