Wait for method ends...

I have created a method that appear a subtitle on the screen and play a voice sound at the same time… But unity must await the completion of the implementation of the method and then continue.

Like this:

C#
void Update()
{
   Legenda(1);
   // then wait for the completion
   Legenda(2);
   ...
}

How can i do this?:face_with_spiral_eyes:

You can’t use Update for that; use coroutines instead.

function Start () {
	yield Function1();
	Function2();
}

–Eric

Eric, I wrote this:

void Start ()
{
	Joemerson.a = 1;       //Joemerson it's a color XD
	Joemerson.b = 0;
	Joemerson.g = 0;
	Joemerson.r = 0.75f;
	yield Legenda(1);
	Legenda(23);
}

and doesn’t worked!

This appear on the console:

Assets/LegendasVozes.cs(79,30): error CS1525: Unexpected symbol `(', expecting `)', `,', `;', `[', or `='

C# has a different syntax.

http://unity3d.com/support/documentation/ScriptReference/index.Coroutines_26_Yield.html

–Eric

Ok… I’ll try to use this method, what have I created using C#, in another Java Script to use the simple yield that you mentioned.

Thanks…