yield

作者: 一枚64byte的仙女 | 来源:发表于2021-08-19 16:13 被阅读0次

yield不可单独使用

需要与return配合使用,例如:

1 yield return 0; //等0帧

2 yield return 1; //等1帧

3 yield return WaitForSeconds(3.0); //等待3秒

所有使用yield的函数必须将返回值类型设置为IEnumerator类型

IEnumerator DoSomeThingInDelay() {...}

所有IEnumerator类型函数必须使用”StartCoroutine”这个函数触发,不能单独使用

StartCoroutine(DoSomeThingInDelay());

相关文章

网友评论

      本文标题:yield

      本文链接:https://www.haomeiwen.com/subject/apkabltx.html