Coroutine

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.

Example

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);
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.44.143