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

 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");

 

相关文章:

  • 2022-12-23
  • 2021-12-25
  • 2021-10-12
  • 2021-08-27
  • 2021-04-02
  • 2021-10-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-30
  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
相关资源
相似解决方案