O'Reilly logo

Unity 3 Game Development HOTSHOT by Jate Wittayabundit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

StopCoroutine

Stops all coroutines for the specific method name running on this behavior.

Tip

Only StartCoroutine using a string method name can be stopped using StopCoroutine.

Example

function Start() {
/  / Start Coroutine DoSomething
  StartCoroutine("DoSomething", 5.0); 

  //  Wait for 2 seconds
  yield WaitForSeconds(2.0);

  // Stop Coroutine DoSomething
  StopCoroutine("DoSomething");
}

function DoSomething (someParameter : float) {
  while (true) {
    // DoSomething Loop
    Debug.Log ("DoSomething Loop = " + Time.time);
    // Yield execution of this coroutine and return to the main loop until next frame
    yield;
  }
}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required