Unity3D之协程(Coroutines Yield ).docVIP

  • 6
  • 0
  • 约3.08千字
  • 约 5页
  • 2016-08-23 发布于河南
  • 举报
Unity3D之协程(Coroutines

Unity3D之协程(Coroutines Yield ) 写游戏代码,往往最终需要代码为连续的事件.结果会像这样: [它可以实现将一段程序延迟执行或者将其各个部分分布在一个时间段内连续执行。] span?style=font-size:18px;private?int?state?=?0;?? void?Update()?? {?? ????????if?(state?==?0)??? ????????{?? ????????????????//做步骤0?? ????????????????state?=?1;?? ????????????????return;?? ????????}?? ????????if?(state?==?1)??? ????????{?? ????????????????//?做步骤1?? ????????????????state?=?2;?? ????????????????return;?? ????????}?? ????????//?...?? }?/span?? 往往使用yield语句更为方便.yield语句是一个特殊的返回类型,它确保函数从yield语句的下一行继续执行. span?style=font-size:18px;while(true)?{?? ????????//?做步骤0?? ????????yield?ret

文档评论(0)

1亿VIP精品文档

相关文档