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

Python能开发WordPress女生做seo网站推广

Python能开发WordPress,女生做seo网站推广,帝国做网站是选择静态还是伪静态,利于优化的网站一.携程概述 官方的解释是,携程允许你可以在多个帧中执行任务。在Unity中,携程是一个可以暂停并在后续帧中从暂停处继续执行的方法。 二.携程写法 下面示例使用携程和Update打印前5帧的时间间隔,展示了携程的基础写法 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.15wanjia.com/news/177955.html

相关文章:

  • 网站关键词优化原理电商网站开发背景怎么写
  • 个人网站做seo写一个网页需要什么技术
  • 哪个网站有上门做指甲制作招聘网页
  • 网站建设dns解析设置云南建设项目招标公告发布网站
  • 爱站数据金蝶在线登录入口
  • 如何绑定网站域名wordpress 仿站
  • 无锡网站制作优化推广公司中卫网站设计公司排名
  • 海洋网站建设网络公司老榕树建站软件
  • 没有备案的网站怎么访问营销型网站建设定制网站建设
  • 彩票网站怎么做代理网站模板的缺点
  • 企业网站建设步骤网站运营推广公司
  • 网站备案密码重置申请表wordpress数据清除缓存
  • 域名已有服务器也有怎么做网站开发网站如何选需要注意什么
  • 遂川网站建设户型图装修设计图app
  • 成都手机微信网站建设报价单用psd做的买书网站
  • 网站开发和网络安全创新的商城网站建
  • 网站建设是设wordpress建站以后
  • 青岛网站建设首选怎么更改wordpress文件上传大小
  • dedecms网站管理系统网站建设的教学设计
  • 网站后台信息发布这样做佛山网站排名优化
  • 手机网站建设进度今天的新闻内容50字
  • 朝阳网站seo外贸网站seo怎么做
  • 邯郸做网站询安联网络领诺科技网站建设
  • 网站制作机构网站二次开发多少钱
  • cm域名做网站镇巴作风建设网站
  • 南宁网站建设长春微信商城开发报价
  • 做网站全体教程网络营销设计
  • arial 网站开发是用犀利wordpress连连支付
  • wordpress 站点主页软件定制开发的发展前景
  • 兰州网站备案网站开发报告参考文献