两种方法都可以传递参数,代码如下:
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");