您的位置:首页 > 移动开发 > Unity3D

unity IEnumerator 协同程序

2013-09-30 11:12 393 查看
中断语句的使用

IEnumerator Awake() {
yield return new WaitForSeconds(5.0F);
}


do等待2秒后执行后面的语句

IEnumerator Do() {
print("Do now");
yield return new WaitForSeconds(2);
print("Do 2 seconds later");
}
void Awake() {
Do();
print("This is printed immediately");
}


先执行do等待都执行结束再执行其他的

IEnumerator Do() {
print("Do now");
yield return new WaitForSeconds(2);
print("Do 2 seconds later");
}
IEnumerator Awake() {
yield return StartCoroutine("Do");
print("Also after 2 seconds");
print("This is after the Do coroutine has finished execution");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: