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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM