Below is my code. I expect test to be “True” after I call “revert(test)”. However, Debug.Log prints out “The value of test in GameManager is False”. In the Start() function, if I just write “test = !test” then test would equal to “True”. I don’t know what’s wrong with my code.
#pragma strict
var test : boolean = false;
function revert (a : boolean)
{
a = !a;
}
function Start () {
revert (test);
Debug.Log ("The value of test in GameManager is " + test);
}
function Update () {
}
#pragma strict
var test : boolean = false;
function revert (a : boolean) : boolean {
return !a;
}
function Start () {
test = revert (test);
Debug.Log ("The value of test in GameManager is " + test);
}