MonoBehaviour.StopAllCoroutines 停止所有协同程序

function StopAllCoroutines () : void

Description描述

Stops all coroutines running on this behaviour.

停止所有动作的协同程序。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	IEnumerator DoSomething() {
		while (true) {
			yield return null;
		}
	}
	public void Awake() {
		StartCoroutine("DoSomething");
		StopAllCoroutines();
	}
}
// Starts the coroutine
// 开始协同程序.
StartCoroutine ("DoSomething");
// Cancels the coroutine immediately afterwards
// 随后立即取消之.
function DoSomething () {
	while (true) {
		yield;
	}
}
StopAllCoroutines();
Page last updated: 2011-1-2