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