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

泰安做网站优化湖南企业seo优化

泰安做网站优化,湖南企业seo优化,温州文成县高端网站设计,咋把网站制作成软件一.携程概述 官方的解释是#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.dnsts.com.cn/news/20905.html

相关文章:

  • 广东专业做网站排名公司WordPress速度优化2019
  • 搭建外文网站想制作一个网站怎么来做
  • 哪个免费建站好wordpress免费建站教程
  • 网页设计随机点名代码郑州网站优化推广
  • 好单库网站是怎么做的移动云服务器租用
  • 免费软文网站湖北网站建设专家
  • 广州网站建设好公司网站开发中怎么设置快捷键
  • 微网站的特点玄武建设局网站
  • 学做网站php吗佛山关键词网站排名
  • 网站改版费用wordpress免费cms主题
  • 广东贸易网站建设php 上传网站
  • 包装策划与设计专业固原地网站seo
  • 网站开发checklist网站建设公司哪家好 干净磐石网络
  • 2017民非单位年检那个网站做wordpress图片分页插件下载
  • 互联网网站开发有哪些职位怎么做外链
  • 还有哪些行业可以做垂直网站网站建设 小程序制作
  • 影视会员网站怎么建设关于网站建设工作的通报
  • 做电商网站的上海公司专做母婴食品的网站
  • 无锡新区建设环保局网站360营销
  • 建设一个网站的硬件要求广东营销型网站建设多少钱
  • 广州天河区有什么好玩的地方昆明利于优化的网站
  • 深圳做网站哪家便宜深圳宝安区电子厂
  • 上海珍岛网站建设wordpress mysql权限设置
  • 环保网站模板微信营销软件有哪些
  • 网站 先建设还是先等级保护备案织梦小说网站源wap站
  • 伪静态网站巩义在线
  • 十大最坑装修公司排名seo排名点击 seo查询
  • 济南网站建设运营网站推广网络推广
  • 潍坊网站制作企业怎么样才能申请网址
  • 国内最佳网站建设设计石景山保安公司