I can’t find how to access a variable from another script in the Unity 5. I know the changed some things but i just can’t get it right. In the old Unity i used var TheScript : Script;
and then to call it TheScript.AVarFromTheScript = false;
. That doesn’t seem to work anymore. I get the error unknown identifier. I also checked this page out but i can’t get it working.
Seems to work just fine.
ScriptA.js:
#pragma strict
var otherScript : ScriptB;
print(otherScript.someVariable);
ScriptB.js:
#pragma strict
var someVariable : String = "Hello World!";
Do you perhaps have other errors in your project? Check the console for hints. Typos? Are you sure you got the variable name correct?