将下面代码绑在模型上面
var tempTime : float;
function Start()
{
tempTime = 0;
}
function Update () {
if(tempTime < 1)
{
tempTime = tempTime + Time.deltaTime;
}
if(renderer.material.color.a >0)
{
renderer.material.color.a = 1 - tempTime;
}
//print(renderer.material.color.a);
}
再把模型的shader改成透明的那一个Transparent/Diffuse
||||||||||||||||||||||||||||||||||||||| 模型变色 ||||||||||||||||||||||||||||||||||||
很简单。。。。
var colorStart = Color.red;
var colorEnd = Color.green;
var duration = 1.0;
var minimum = 0.0;
var maximum = 200.0;
function Update () {
var lerp = Mathf.PingPong (Time.time, duration) / duration;
renderer.material.color = Color.Lerp (colorStart, colorEnd, lerp);
transform.position.x = Mathf.Lerp(minimum, maximum, lerp);
}