Game Development Reference
In-Depth Information
Debug.Log (Time.time);
}
You can both stack and chain coroutines .
The following example will execute Do but will coninue ater calling Do immediately:
function Start() {
Do();
Debug.Log ("This is printed immediately");
}
function Do() {
Debug.Log ("Do now");
yield WaitForSeconds (5); //Wait for 5 seconds
Debug.Log ("Do 5 seconds later");
}
The following example will execute Do and wait unil it is inished before coninuing its
own execuion:
//Chain Coroutine
function Start() {
//The below line is similar to the yield Do(); only if you
are using Unity JavaScript. However, if you use C#, you must use
StartCoroutine . (For more details in the Appendix C)
yield StartCoroutine(Do());
Debug.Log ("This is printed after 5 seconds");
Debug.Log ("This is after the Do coroutine has finished execution");
}
function Do() {
Debug.Log ("Do now");
yield WaitForSeconds (5); //Wait for 5 seconds
Debug.Log ("Do 5 seconds later");
}
WaitForFixedUpdate
Waits unil the next frame rate of FixedUpdate funcion. (For more details have a look at
Appendix A , Important Funcions. )
WaitForFixedUpdate can only be used with a yield statement in coroutines .
 
Search WWH ::




Custom Search