wait for input?

if i want to use

if(Input.GetButtonDown("up")

outside the Update function it doesnt work because unity is not checking if the player is clicking on up EVERY FRAME
i want it to happen on a function i create that isnt getting update every frame, a function that go row, row, row until it reaches it end. is there a way doing that?

Anyone?..

has to check every frame. period.

however, you can structure it like this:

void update ()
{
FirstFunction ();
SecondFunction ();
}

void FirstFunction ()
{
//Does this first
}

void SecondFunction ()
{
//Does this after doing FirstFunction
}

Bump! I want to know!
i’m trying this way but with no sucess:

function WaitInput(key : String) { // this need to be a coroutine
	while(Application.isPlaying)
	{
		if(Input.GetButtonDown(key)){
			yield;
		}
	}
}

But the editor freezes and stops to respond…
Why always i use the command while the editor freezes???

The editor is freezing because you are only yielding the coroutine if there is input, so when there is no input you are creating an infinite loop. Try adding a yield like this:

function WaitInput(key : String) { // this need to be a coroutine
	while(Application.isPlaying)
	{
		if(Input.GetButtonDown(key)){
			yield;
		}
                yield;
	}
}

THANKSSS! It works perfectly… I thought the “yield” was the coroutine warn: “Im Finished!”… =p
Very thanks men!