Material.Lerp 插值

function Lerp (start : Material, end : Material, t : float) : void

Description描述

Interpolate properties between two materials.

在两个材质之间插值

Makes all color and float values of a material be interpolated from start to end, based on t.
给一个材质所有颜色和浮点值作一个插值,从差值开始到结束都基于时间t。

When t is 0, all values are taken from start.
时间t 为 0时,所有值为开始。

When t is 1, all values are taken from end.
时间t 为 1时,所有值为结束。

Most often you want the materials that are interpolated between to be the same (use the same shaders and textures) except for colors and floats. Then you use Lerp to blend between them.

通常,您想要差值的两个材质是相同的(使用相同的着色器和纹理) 除了颜色和浮点数。然后您可以使用 Lerp 做它们之间的混合。

参见: Materials .

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Material material1;
	public Material material2;
	public float duration = 2.0F;
	void Start() {
		renderer.material = material1;
	}
	void Update() {
		float lerp = Mathf.PingPong(Time.time, duration) / duration;
		renderer.material.Lerp(material1, material2, lerp);
	}
}
// Blends between two materials
//两种材质间的混合

var material1 : Material;
var material2 : Material;
var duration = 2.0;

function Start () {
	// At start, use the first material
	//在启动时,使用第一个材质
	renderer.material = material1;
}

function Update () {
	// ping-pong between the materials over the duration
	//根据时间变化来回变化材质

	var lerp : float = Mathf.PingPong ( Time.time , duration) / duration;
	renderer.material.Lerp (material1, material2, lerp);
}
最后修改:2011年1月22日 Saturday 21:46

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。