当前位置: 首页 > news >正文

网站正在建设页面模板高价做单网站

网站正在建设页面模板,高价做单网站,海南网站建设制作,北京东直门 网站建设一.携程概述 官方的解释是#xff0c;携程允许你可以在多个帧中执行任务。在Unity中#xff0c;携程是一个可以暂停并在后续帧中从暂停处继续执行的方法。 二.携程写法 下面示例使用携程和Update打印前5帧的时间间隔#xff0c;展示了携程的基础写法 using System.Colle…一.携程概述 官方的解释是携程允许你可以在多个帧中执行任务。在Unity中携程是一个可以暂停并在后续帧中从暂停处继续执行的方法。 二.携程写法 下面示例使用携程和Update打印前5帧的时间间隔展示了携程的基础写法 using System.Collections; using System.Collections.Generic; using UnityEngine;public class demo2 : MonoBehaviour {private int frameNum 1;void Start(){StartCoroutine(coroutine);}public IEnumerator coroutine(){Debug.Log(coroutine frame1: Time.deltaTime);yield return null;Debug.Log(coroutine frame2: Time.deltaTime);yield return null;Debug.Log(coroutine frame3: Time.deltaTime);yield return null;Debug.Log(coroutine frame4: Time.deltaTime);yield return null;Debug.Log(coroutine frame5: Time.deltaTime);yield return null;}void Update(){if (frameNum 5){Debug.Log(------ Update: frameNum Time.deltaTime);frameNum;}} } 从打印结果来看携程和Update一样会每帧调用一次StartCoroutine用于开启携程返回值类型固定为IEnumerator返回值yield return null表示下一帧从此处之后开始执行等同于yield return 一个数字 这里IEnumerator接口和yield关键字是C#的不了解的可查看前两篇文章 三.Unity规定的携程返回值含义(标红的较为常用) 代码含义yield return null;  yield retun x(x代表任意数字)下一帧再执行后续代码 yield return new WaitForSeconds(0.1f); yield return new WaitForSecondsRealtime(0.1f); //不受timescale影响 等待固定时间执行后续代码yield return FunctionName();函数执行完毕后执行后续代码yield return Coroutine;协程执行完毕后执行后续代码yield return new WaitForEndOfFrame();帧渲染完成后执行后续代码yield return new WaitForFixedUpdate();物理帧更新后执行后续代码yield break;结束该协程yield return startCoroutine(funcName)等携程funName结束后执行后续代码 四.携程在事件函数中的执行顺序 using System; using System.Collections; using System.Collections.Generic; using UnityEngine;public class demo1 : MonoBehaviour {private bool logStart true;void Start(){StartCoroutine(coroutine1);}void Update(){if (Input.GetKeyDown(KeyCode.S)){logStart !logStart;Debug.Log(logStart);}if (logStart){Debug.Log(-------------------);Debug.Log(Update: Time.deltaTime);}}void LateUpdate(){if (logStart){Debug.Log(LateUpdate: Time.deltaTime);}}public IEnumerator coroutine1(){while (true){if (Input.GetKeyDown(KeyCode.S)){yield break;}else{Debug.Log(coroutine1: Time.deltaTime);yield return null;}}} }从打印结果来看携程在Update之后LateUpdate之前执行官网的事件函数示意图也说明了这一点 五.携程的作用 1.替代Update处理一些耗时按帧执行的任务避免Update过于复杂 2.处理调用耗时API(比如切换场景)完成后在做什么的情况 六.携程可以传参可以嵌套 下面例子演示了crt1等待crt2结束后再执行后续并给crt2传递参数 using System.Collections; using System.Collections.Generic; using UnityEngine;public class demo2 : MonoBehaviour {void Start(){StartCoroutine(crt1);}public IEnumerator crt1(){Debug.Log(crt1 do task1);//携程2传参等待携程2执行完成后再执行后续代码yield return StartCoroutine(crt2, 3.0f);Debug.Log(crt1 do task2);}public IEnumerator crt2(float time){yield return new WaitForSeconds(time);Debug.Log(crt2 do task after time sec);yield return new WaitForSeconds(2);Debug.Log(crt2 finish);}void Update(){if (Input.GetKeyDown(KeyCode.S)){StopCoroutine(crt2);Debug.Log(crt2 is stopped);}if (Input.GetKeyDown(KeyCode.A)){StopAllCoroutines();Debug.Log(All crt stopped);}} }七.停止携程 StopCoroutine(funcName); //停止携程funcName StopAllCoroutines(); //停止脚本内所有携程
http://www.w-s-a.com/news/890035/

相关文章:

  • 网站后台演示地址服装网站建设公司推荐
  • 湖北钟祥建设局网站旅游哪个网站最好
  • 浙江建设工程信息网站辽宁建设工程信息网场内业绩什么意思
  • 郑州做网站公司 汉狮网络专业图片搜集网站怎么做
  • 网站托管是什么品牌推广营销平台
  • 制作网站的难度贵州省兴义市建设局网站
  • 永春建设局网站室内设计师培训班学费多少
  • 做仿站如何获取网站源码windows2012做网站
  • 网站建设最好的公司东莞外贸网站
  • 普兰店网站建设一般做网站什么价格
  • 网站建设的发展目标甘肃网站设计公司
  • 常州西站建设规划室内装修设计学校哪里好
  • 大连网站制作选择ls15227如何编辑网站
  • 网站发稿平台迪士尼网站是谁做的
  • 常州有哪些好的网站建设案例wordpress 360 插件
  • 模板网站有后台么柳城网站建设
  • 地方门户网站制作一级做c爱片的网站
  • 自己上传图片做动漫图网站北京福田汽车
  • 一级a做爰片免费网站录像ps做网站图片水印
  • 网页广告投放成都优化推广公司
  • 网站开发 印花税网页制作站点
  • 创建个人网站有什么好处国外建站系统
  • 桂林学校网站制作2018年网站设计公司
  • 建网站不想用怎样撤销搜狗收录提交入口网址
  • 做简单网站需要学什么软件有哪些南通优普网站建设
  • 网站排版尺寸湖北交投建设集团集团网站
  • 南京网站设计公司有哪些公司看动漫是怎么做视频网站
  • vs做网站怎么做窗体怎么在电脑上自己做网站吗
  • 做网站应该学什么网站编程 外包类型
  • 双鱼儿 网站建设站群系统哪个好用