关于 int Mathf.PingPong(t, length); 原理,相当于

#include <iostream>
#include <vector> int test(int t, int length)
{
if(t / length % == )
return length - t % length;
else
return t % length;
} int main()
{
int length = ;
std::vector<int> vect{,,,,,,,,};
for(auto& item : vect)
{
std::cout<<test(item,length)<<",";
}
}

说明参见:http://forum.unity3d.com/threads/mathf-repeat-vs-mathf-pingpong.1388/

类似的还有 Color.Lerp    / Vector3.Lerp

在 Update 里调用  Color32.Lerp(colorWhite, colorBlack, Time.time); 一般是指在1秒钟内完成变色,但如果一开始Time.time就不等于0,则结果不是这样,假设Time.time开始执行时就>1,则执行到此代码时,立即变色,如下:

float time = ;

void Update () {
time += Time.deltaTime;
if(time>)
{
Color c = Color32.Lerp(Color.white, Color.black, Time.time);
Debug.Log(c.r + "," + c.g + "," + c.b);
gameObject.GetComponent<Image>().color = c;
}
}

如果要使用3秒时间完成变色,则需要如下代码:

float time = ;

void Update () {
gameObject.GetComponent<Image>().color = Color32.Lerp(Color.white, Color.black, time);
time += Time.deltaTime / ;
}

Time.time是指

unity 协程

调用 StartCoroutine ,相当于创建并进入了另一个线程,并执行其中的函数,直到遇到第一个 yield return,此时协程暂停,然后将程序执行权返还给调用函数,什么时候恢复执行是根据 yield return 后面的参数决定的,如果是 yield return null; 表示一帧后恢复,如果是 yield return new WaitForSeconds(3); 表示3秒后恢复,如果后面跟一个对象,则该对象不为 nil 时恢复 。

Unity API的更多相关文章

  1. 离线unity API文档

    只要安装的时候勾选上document 打开unity选择help-ScriptReference就可以打开本地API了.

  2. unity API 之EventSystem.current.IsPointerOverGameObject()

    命名空间 :UnityEngine.EventSystems 官方描述: public bool IsPointerOverGameObject(); public bool IsPointerOve ...

  3. Unity API 解析 (陈泉宏著)

    1 Application类 2 Camera类 3 GameObject类 4 HideFlags类 5 Mathf类 6 Matrix4x4类 7 Object类 8 Quaternion类 9 ...

  4. Unity API学习笔记(1)

    首先创建测试项目: 这里我选择了2D,其实都可以,之后可以在项目中修改. 修改方法: 进入正题. 首先看一下官方提供的>手册和>脚本API文档. 创建C#脚本文件并打开: 默认的脚本文件为 ...

  5. Unity API 解析(13)—— Vector3 类

    三维向量或三维坐标点 normalized —— 单位化向量 返回方向相同模长为1的向量 sqrMagnitude —— 模长平方 Scale —— 向量缩放 Angle —— 两向量夹角 Cross ...

  6. Unity API学习笔记(2)-GameObject的3种Message消息方法

    官方文档>GameObject 首先建立测试对象: 在Father中添加两个脚本(GameObejctTest和Target),分别用来发送Message和接受Message: 在其它GameO ...

  7. Unity API笔记

    1. 返回某范围的随机数 Random.Range method. static float Range(float min, float max); returns a float – return ...

  8. Unity中文API参考手册

    转载请标明原文地址:http://www.cnblogs.com/zhangyukof/p/6835582.html  Unity5中文脚本手册 网页版 Unity API 执行顺序: Unity5中 ...

  9. 快速上手Unity原生Json库

    现在新版的Unity(印象中是从5.3开始)已经提供了原生的Json库,以前一直使用LitJson,研究了一下Unity用的JsonUtility工具类的使用,发现使用还挺方便的,所以打算把项目中的J ...

随机推荐

  1. 【poj3615】 Cow Hurdles

    http://poj.org/problem?id=3615 (题目链接) 题意 给出一张有向图,求从u到v最大边最小的路径的最大边.→_→不会说话了.. Solution 好久没写Floyd了,水一 ...

  2. 【poj1985】 Cow Marathon

    http://poj.org/problem?id=1985 (题目链接) 题意 求树上两点间最长距离.题目背景以及输入描述请见poj1984. Solution 树的直径. 代码 // poj198 ...

  3. codeforces 580D:Kefa and Dishes

    Description When Kefa came to the restaurant and sat at a table, the waiter immediately brought him ...

  4. css3的@media媒体查询

    css3新功能,根据屏幕大小进行识别. 参考: http://www.runoob.com/cssref/css3-pr-mediaquery.html

  5. Windows_7_休眠按钮没有了_如何找回?

    1. 在运行中输入:   powercfg -h on或者在命令行下输入:   powercfg.exe /hibernate on注意:执行这个命令需要管理员权限. “休眠”回来了   2. 还是没 ...

  6. 我总结的js性能优化的小知识

    前言 一直在学习javascript,也有看过<犀利开发Jquery内核详解与实践>,对这本书的评价只有两个字犀利,可能是对javascript理解的还不够透彻异或是自己太笨,更多的是自己 ...

  7. POJ1915Knight Moves(单向BFS + 双向BFS)

    题目链接 单向bfs就是水题 #include <iostream> #include <cstring> #include <cstdio> #include & ...

  8. mysql中max_allowed_packet参数的配置方法(避免大数据写入或者更新失败)

    修改方法 1.修改配置文件 可以编辑my.cnf来修改(windows下my.ini),在[mysqld]段或者mysql的server配置段进行修改. 代码如下: max_allowed_packe ...

  9. python 动态调用模块、类、方法(django项目)

    需求:近一段时间基于django框架,开发各业务层监控代码,每个业务的监控逻辑不同,因此需要开发监控子模块,动态的导入调用. 项目名称:demo_django App:common_base.moni ...

  10. Yocto开发笔记之《快速入门,环境搭建 & 编译》(QQ交流群:519230208)

    开了一个交流群,欢迎爱好者和开发者一起交流,转载请注明出处. QQ群:,为避免广告骚扰,申请时请注明 “开发者” 字样 ======================================== ...