停止在该行为上运行的所有协同程序。
        
                    MonoBehaviour 可以执行零个或多个协同程序。
                    创建的协同程序可以执行一段时间。
                    在下面的脚本示例中,我们创建并运行了两个协同程序。
                    但使用了 StopAllCoroutines 来停止它们。
                    可以在运行多个协同程序的脚本上执行该操作。
                    不需要参数,
                    因为这将停止脚本上的所有协同程序。
__注意:__.StopAllCoroutines 仅对其附加到的脚本进行操作。
                
      
using UnityEngine; using System.Collections;
// Create two coroutines that run at different speeds. // When the space key is pressed stop both of them.
public class ExampleClass : MonoBehaviour { //coroutine 1 IEnumerator DoSomething1() { while (true) { print("DoSomething1"); yield return new WaitForSeconds(1.0f); } }
//coroutine 2 IEnumerator DoSomething2() { while (true) { print("DoSomething2"); yield return new WaitForSeconds(1.5f); } }
void Start() { StartCoroutine("DoSomething1"); StartCoroutine("DoSomething2"); }
void Update() { if (Input.GetKeyDown("space")) { StopAllCoroutines(); print("Stopped all Coroutines: " + Time.time); } } }