OnGUI and WaitForSeconds

Hi,

couldn’t find it anywhere, so I’m asking you experts here:

how can I postpone a start of the OnGUI function since yield WaitForSeconds can’t be used in an OnGUI function?

I want that my OnGUI function starts 3 seconds after start.

/* Example level loader */
var style1 : GUIStyle;


function OnGUI () {
	
	// Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
	if (GUI.Button (Rect (120,390,180,50), "Level 1", style1)) {
		Application.LoadLevel (1);
	}

	// Make the second button.
	if (GUI.Button (Rect (120,470,180,50), "Level 2", style1)) {
		Application.LoadLevel (2);
	}
}

thanks!

make a coroutine and in that coroutine you can use yield WaitForSeconds()

a coroutine in the same script?
how?
:slight_smile:

tnx!

get Time.time variable …
then asign it every time u run ur script…
and use if to check old time + distance with now time…

but if u mean make it wait… even if u can ur game performance will reduce … cuz OnGUI is draw function and call each frame…

maybe I wasn’t clear enough:
I want that OnGUI starts 3 seconds after my game starts (only once) = I want a delay before OnGUI.

tnx!