I wrote a script that should disable after 4 seconds the OnGUI function, but when I tried, the function OnGUI still working after 4 seconds.
This is my JavaScript:
#pragma strict
var x : boolean = true;
function Start () {
yield WaitForSeconds(4);
x = false;
}
function Update () {
if(x == true){
OnGUI();
}
}
function OnGUI(){
GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 100, 400, 30), "What's that noise? It's was form the living room...");
}
Can anyone help me? Thanks!