StartCoroutine
returns a coroutine. Instances of this class are only used to reference these coroutines and do not hold any exposed properties or functions.
A coroutine
is a function that can suspend its execution of yield
until the given YieldInstruction
finishes.
function Start() { // Starting = 0.0 Debug.Log ("Starting = " + Time.time); // Start function WaitAndPrint as a Coroutine yield WaitAndPrint(); // Done WaitAndPrint = 5.0 Debug.Log ("Done WaitAndPrint = " + Time.time); } function WaitAndPrint() { //Suspend execution for 5 seconds yield WaitForSeconds(5); // WaitAndPrint = 5.0 Debug.Log ("WaitAndPrint = " + Time.time); }
18.216.44.143