本文共 1174 字,大约阅读时间需要 3 分钟。
public StartCoroutine(string methodName, object value = null);
Starts a coroutine named methodName
.
In most cases you want to use the StartCoroutine variation above. However StartCoroutine using a string method name allows you to use with a specific method name. The downside is that the string version has a higher runtime overhead to start the coroutine and you can pass only one parameter.
// In this example we show how to invoke a coroutine using a string name and stop it function Start () { StartCoroutine("DoSomething", 2.0); yield (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; }}
using UnityEngine;using System.Collections; public class ExampleClass : { IEnumerator Start() { StartCoroutine("DoSomething", 2.0F); yield return new (1); StopCoroutine("DoSomething"); } IEnumerator DoSomething(float someParameter) { while (true) { print("DoSomething Loop"); yield return null; } }}
转载地址:http://diwno.baihongyu.com/