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");
posted @ 2017-11-10 10:44  千喜ya  阅读(2491)  评论(0)    收藏  举报