簡體   English   中英

Unity3D協程編譯器錯誤

[英]Unity3D Coroutine compiler error

我是一個團結完整的初學者,並且我想使用協程播放動畫,但是會出現以下錯誤:

1.錯誤CS1502: UnityEngine.MonoBehaviour.StartCoroutine(System.Collections.IEnumerator)' has some invalid arguments 2.error CS1503: Argument的最佳重載方法匹配UnityEngine.MonoBehaviour.StartCoroutine(System.Collections.IEnumerator)' has some invalid arguments 2.error CS1503: Argument 1無法將System.Collections.IEnumerable' expression to type轉換System.Collections.IEnumerable' expression to type System。 Collections.IEnumerator'


編碼:

     using UnityEngine;
using System.Collections;

public class Trap : MonoBehaviour {

    //public float delayTime;


    // Use this for initialization
    void Start () {
        StartCoroutine (Go ());
    }

    // Update is called once per frame
    void Update () {

    }

    IEnumerable Go(){
        while (true) {
            animation.Play();
            yield return new WaitForSeconds(3f);
        }
    }

}

更改

IEnumerable Go(){
    while (true) {
        animation.Play();
        yield return new WaitForSeconds(3f);
    }
}

對於IEnumerator ...

IEnumerator Go(){
    while (true) {
        animation.Play();
        yield return new WaitForSeconds(3f);
    }
}

協程的返回類型將是IEnumerator。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM