OnGUI waiting for x seconds before turning it off

Ok, so second newbish questions for me.
I have a keypad that shows up using OnGUI.
after the user press the correct code, i want to wait for 2 seconds then turn off the gui.
Everything in my code works except for the turning off the gui.
I tried with using a var and say if showGUI == fales then run the gui code.

anyhow, here is the the code… it’s long >_<

var ShowGUI : boolean = false;
var creationTime:float = 0.0;

function Update() {

if (Time.time >= creationTime + 2.0 && numberString =="1234")
	ShowGUI = true;
	print (ShowGUI);

function OnGUI ()
if (ShowGUI == false)
//create gui for 12 buttons 1-0 + E and C

			{// pushing the button C on the keypad does this

				lock = true;
				creationTime = Time.time;


Well, because your question really isn’t formatted very well (lots of white-space, lots of irrelevant parts) I haven’t read through it all, but I think in this case what you need is this:

Assuming you have a boolean that controls whether the GUI draws or not:

When the conditions for making the GUI disappear are met, do something like this:


function WaitAndDisableGUI(time : float)
    yield WaitForSeconds(time);
    showGUI = false;