I have a script in which I press onGUI and it should change a static boolean to false, and load a new scene.
When running the script, whichever command is listed second will run on start-up, while the first works correctly and only triggers when pressing the GUI.
When running the same script with OnMouseDown it works as intended - Both events happen when the mouse is pressed on the relevant object.
When removing the secondary function, each one works in isolation with no issues.
Having hacked this together with little knowledge of what I’m doing, I was hoping someone could explain where I have tripped up. Thanks!
static var active : boolean = true;
var string = "Level name";
var customButton : GUIStyle;
function OnGUI () {
//the active script changes to false - this will prevent the score from updating anymore
if (GUI.RepeatButton(Rect (200,200,200,200), "", customButton))
active = false;
Application.LoadLevel(string);
}