I am getting a unknown identifier error when trying to change a variable with a GUI button. I don't know what is causing it because it should be recognized. Here is the code: Code (JavaScript): #pragma strict var gameDif = "Easy"; var gameDifInternal = 1; function OnGUI () { if (GUI.Button (Rect (820,400,300,200), "Difficulty: " + gameDif)){ gameDifInternal++; } if(gameDifInternal == 1){ gameDif = "Easy"; } else if(gameDifInternal == 2){ gameDif = "Normal"; } else if(gameDifInternal == 3){ gameDif = "Hard"; } if(gameDifInternal == 4 || gameDifInternal > 3){ gameDif = "Easy"; gameDifInternal = 1; } } . Please help!
The code you posted doesn't generate any errors. But you should use arrays instead of coding a bunch of separate if/then statements. --Eric
The point is that it does create an error, but i don't know why it does. It gives an unknown identifier error at line 6. The problem is that I don't know why it is creating an error because the variable is defined.
Except that it doesn't. I didn't see any issues with a quick scan, so I copied and pasted it into Unity, and no errors. --Eric