当前位置: 移动技术网 > IT编程>开发语言>.net > Unity协程基础用法

Unity协程基础用法

2019年04月29日  | 移动技术网IT编程  | 我要评论

阳仔演笑会3,硫化机厂家,安阳市新闻网

//通过startcoroutine()开始一个协程


//通过stopcoroutine();关闭一个协程


//通过stopallcoroutines()方法来实现关闭所有协程


void start()


{


debug.log("开始协程程序:执行开始时间:"


+ time.time);


startcoroutine("ie_demo1");





//开始2个协程分别输出猪八戒和沙悟净


startcoroutine("ie_demo2");


startcoroutine("ie_demo3");


//关闭输出沙悟净的协程结果只输出了孙悟空 和猪八戒。沙悟净的关闭了。


stopcoroutine("ie_demo3");








}


//简单使用1


ienumerator ie_demo1()


{


debug.log("进入1协程时间:" +


time.time);


yield return new waitforseconds(1);//等待1秒


debug.log("输出孙悟空,时间:" +


time.time);


}


//简单使用2


ienumerator ie_demo2()


{


debug.log("进入2协程时间:" +


time.time);


yield return new waitforseconds(3);//等待3秒


debug.log("输出猪八戒,时间:" +


time.time);


}


//简单使用3


ienumerator ie_demo3()


{


debug.log("进入3协程时间:" +


time.time);


yield return new waitforseconds(3);//等待3秒


debug.log("输出沙悟净,时间:" +


time.time);


}


更多unity2018的功能介绍请到paws3d爪爪学院查找。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网