Unity3D协程 Unity带参数的协程

Unity带参数的协程

两种方法都可以传递参数,代码如下:

复制代码
 1 using UnityEngine;
 2 using System.Collections;
 3 
 4 public class Test : MonoBehaviour
 5 {
 6     void Start()
 7     {
 8         StartCoroutine("Method", "AaronBlog");
 9         StartCoroutine(Method("AaronBlog"));
10     }
11 
12     IEnumerator Method(string name)
13     {
14         Debug.Log(name);
15         yield return 0;
16     }
17 }
复制代码

停止带参数的协程,方法和停止不带参数的协程方法一样:

1 StopCoroutine("Method");

猜你喜欢

转载自www.cnblogs.com/zwj1276952588/p/10437829.html
今日推荐