function StopCoroutine (methodName : string) : void
Description
Stops all coroutines named methodName running on this behaviour.
Please note that only StartCoroutine using a string method name can be stopped using
StopCoroutine.
function Start () {
StartCoroutine(
"DoSomething", 2.0);
yield WaitForSeconds(1);
StopCoroutine(
"DoSomething");
}
function DoSomething (someParameter :
float) {
while (true) {
print(
"DoSomething Loop");
yield;
}
}
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
IEnumerator
Start() {
StartCoroutine(
"DoSomething", 2.0F);
yield return new WaitForSeconds(1);
StopCoroutine(
"DoSomething");
}
IEnumerator DoSomething(
float someParameter) {
while (true) {
print(
"DoSomething Loop");
yield return null;
}
}
}
import UnityEngine
import System.Collections
class example(MonoBehaviour):
def
Start() as IEnumerator:
StartCoroutine('DoSomething', 2.0F)
yield WaitForSeconds(1)
StopCoroutine('DoSomething')
def DoSomething(someParameter as single) as IEnumerator:
while true:
print('DoSomething Loop')
yield