MonoBehaviour.StopCoroutine 停止协同程序

function StopCoroutine (methodName : string) : void

Description描述

Stops all coroutines named methodName running on this behaviour.

停止这个动作中名为methodName的所有协同程序。

Please note that only StartCoroutine using a string method name can be stopped using StopCoroutine.

请注意只有StartCoroutine使用一个字符串方法名时才能用StopCoroutine停用之.

// In this example we show how to invoke a coroutine using a string name and stop it
// 这个例子演示如何调用一个使用字符串名称的协同程序并停掉它
function Start () {
	StartCoroutine("DoSomething", 2.0);
	yield WaitForSeconds (1);
	StopCoroutine("DoSomething");
}

function DoSomething (someParameter : float) {
	while (true) {
		print("DoSomething Loop");
		// Yield execution of this coroutine and return to the main loop until next frame
		// 停止协同程序的执行并返回到主循环直到下一帧.
		yield;
	}
}
最后修改:2011年1月2日 Sunday 14:18

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。