- Home /
Unity Drops Var Object Assignments on Runtime
When i start my Game, Unity drops all the references i set, i tried deleting and rewriting the script, even deleting it completely and addign it under a new name. everytime i start something that adds runtime- also in the editor on runtime visibly - the assigned GameObjects are set to nothing automatically and i don't know why.
When i start the game or run it theres simply everything there. How can i get the deactivate/reactivate method to work again? I tried puting the "Find" in the Update function. if i create a minor error and put the search before the Start function like:
var ObjectToDeactivate = GameObject.Find("ObjectToDeactivate");
it worked just with a console error, but i corrected it and now there's this bug!
here's an example of one of the corrected scripts, if anyone got a better one that's fine for me. i already accepted assigning tthe objects all anew if it just worked.
Script example:
#pragma strict
var ObjectToDeactivate : GameObject;
ObjectToDeactivate = GameObject.Find("ObjectToDeactivate");
function Start () {
//or like this... both don't work
//ObjectToDeactivate = GameObject.Find("ObjectToDeactivate");
ObjectToDeactivate.SetActiveRecursively(false);
}
function Update () {
}