一个函数以 IEnumerator 开头,而且里面只要有yield语句就行。
并不需要在经过该携程必须经过一次yield语句,例如:下面这种是正确的:
using UnityEngine;
using System.Collections;
public class twoIEnumerator : MonoBehaviour {
int i=3;
// Use this for initialization
void Start () {
StartCoroutine ("f");
}
IEnumerator f()
{
if (i != 3) {
Debug.LogError("In!");
yield return null;
}
Debug.LogError ("Can!");
}
// Update is called once per frame
void Update () {
}
}