Lerp
Lerp,就是返回两个值之间的插值,一般有三个参数。第一个参数为初始值,第二个参数为最终值,插值为0~1d的一个浮点数值,为0时为初始值,1时为最终值,为0到1之间的数值时返回一个混合数值。若第三个参数为Time.daltaTime,这返回随时间推移的一个值。
以Color.Lerp为例
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System; public class ColorChange : MonoBehaviour
{ public Image image;
public float speed;
private Color old;
private Color change;
// Use this for initialization
void Awake ()
{
old = Color.white;
change = Color.green;
image.color = old;
speed=0.5f;
}
void Update()
{ float a = speed * Time.deltaTime; if (this.GetComponent<Image>().color.b > 0.1f)
{
this.GetComponent<Image>().color = Color.Lerp(this.GetComponent<Image>().color, Color.black, a);
}
else
this.GetComponent<Image>().color = change;
}
}
运行之后,白色ugui Image会由白色逐渐变成灰黑色
除了Color之外还有
Material.Lerp
public void Lerp(Material start, Material end, float t);
通常,您想要差值的两个材质是相同的(使用相同的着色器和纹理) 除了颜色和浮点数。然后您可以使用 Lerp 做它们之间的混合。
Color32.Lerp
Quaternion.Lerp
Interpolates between a and b by t and normalizes the result afterwards. The parameter t is clamped to the range [0, 1].
通过t值from向to之间插值,并且规范化结果。
This is faster than Slerp but looks worse if the rotations are far apart.
这个比Slerp更快但是如果旋转较远看起来就比较差。
Mathf.Lerp
Interpolates a towards b by t. t is clamped between 0 and 1.
基于浮点数t返回a到b之间的插值,t限制在0~1之间。
When t = 0 returns from. When t = 1 return to. When t = 0.5 returns the average of a and b.
当t = 0返回from,当t = 1 返回to。当t = 0.5 返回from和to的平均值。
Vector3.Lerp
可以用来控制游戏对象大小,位置什么的,因为,transfrom中的position跟scale,rotation都是一组Vector3
Vector2.Lerp
Vector4.Lerp
Lerp的更多相关文章
- unity3d Vector3.Lerp解析
Vector3.Lerp:http://www.ceeger.com/Script/Vector3/Vector3.Lerp.html 手册中描述的不是很详细,什么叫“按照数字t在from到to之间插 ...
- Vector3.Lerp 插值
Vector3.Lerp 插值 static function Lerp (from : Vector3, to : Vector3, t : float) : Vector3 Description ...
- 对Vector3.Lerp 插值的理解
有时,我们在做游戏时会发现有些跟随动作不够圆滑或者需要一个缓冲的效果,这时,一般会考虑到插值.所以对插值的理解是必需的.(比如摄像机跟随主角) 插值是数学上的一个概念,在这里用公式表示就是:from ...
- 如何正确的使用Lerp In Unity
摘要 本文探讨如何用lerp实现近似的匀速旋转,当然如果运用本文给出的方法,使用slerp则可以实现匀速旋转,并指出Unity官方lerp示例代码的一些缺陷. 现有问题 比如四元数Lerp API: ...
- Unity的Lerp函数实现缓动
在Unity里面Lerp函数可以实现缓动效果 下面例子实现点光源的移动 在场景中创建好一个平面,一个点光源,我在这里随便放了一个模型. 然后新建c#脚本,代码如下: using UnityEngine ...
- [UE4]时间轴线TimeLine,Lerp插值
一.TimeLine时间轴线 勾选“User Last Keyframe”表示使用时间轴最后一个关键帧所在时间点作为结束时间,而不是使用设置的5秒作为结束时间点. 二.Lerp插值 Lerp插值一般与 ...
- UE4 材质Lerp节点解疑
转自:http://www.manew.com/thread-46268-1-1.html 1.A是一个灰色,B是一个红色,Alpha是一个颜色图 A到B是0到1,也就是黑到白,所以,alpha图,黑 ...
- Unity3d 插值Lerp与Slerp
Lerp Lerp表示线性插值. Slerp 球形插值在Vector3.Quaternion等类都有使用,一般多在Quaternion的旋转操作时使用.
- Shader中的lerp
下面解释下什么是lerp的功能: 官方解释 float lerp(float a, float b, float w) { return a + w*(b-a); } 木有看懂 我的解释:把上面的 ...
- 关于 lerp();
value lerp(value s, value a, value b ); 该函数返回的值为:a + s * (b - a) ,是一个处于 [a, b] 之间的值. 当s=0, 该函数返回a :当 ...
随机推荐
- openSTack备份恢复
- docker vim右键进入visual模式无法粘贴
右键不能粘贴,反而进入了visual模式, vim版本:version 8.0.707 修改方法: vim /usr/share/vim/vim80/defaults.vim 第70行 在mouse= ...
- MacOS Laravel 安装教程
一.到官网选择 Laravel 版本 根据个人的喜好选择安装的版本,我选择的是 5.8 https://laravel.com/docs/5.8/installation 以下是 Laravel 5. ...
- typescript - 6.泛型
泛型类 class MinClas<T>{ public list:T[]=[]; add(value:T):void{ this.list.push(value); } min():T{ ...
- 嵌入式LINUX基础教程 第2版
嵌入式LINUX基础教程 第2版 目录 第1章 入门 11.1 为什么选择Linux 11.2 嵌入式Linux现状 21.3 开源和GPL 21.4 标准及相关组织 31.4.1 Linux标准基 ...
- oracle的jdbc 的maven配置
oracle的jdbc是需要收费,因此在maven的中心库是无法下载.有两个办法引入到工程中,一个是手工,另外一个是加入oracle自己的maven库 一.手工配置(本地依赖) 首先要下载到想要的版本 ...
- git删除远程.idea目录
git删除远程.idea目录 1. 登录 Administrator@USER-20180708AB MINGW32 / (master) $ git config --global user.nam ...
- 进入docker 内部
$ sudo docker ps $ sudo docker exec -it 775c7c9ee1e1 /bin/bash
- OpenJudge 4120 硬币
总时间限制: 1000ms 内存限制: 262144kB 描述 宇航员Bob有一天来到火星上,他有收集硬币的习惯.于是他将火星上所有面值的硬币都收集起来了,一共有n种,每种只有一个:面值分别为a1,a ...
- ply2obj
""" Simple script to convert ply to obj models """ import os from argp ...