协程暂停3秒后继续执行
IEnumerator changeColor()
{
print("hha");
yield return new waitforseconds(3);
print("hahah");
}
利用协程操作物体颜色渐变
IEnumerator fade()
{
for(float i=0;i<=1;i=i+0.1f)
{
cube.GetComponent<MeshRenderer>().material.color=new color(i,i,i);
yield return new waitforseconds(0.1f);
}
}
Color.Lerp 插值
static function Lerp (a : Color, b : Color, t : float) : Color
Description描述
Interpolates between colors a and b by t.
通过t在颜色a和b之间插值。
/t/ is clamped between 0 and 1. When t is 0 returns a. When t is 1 returns b.
"t"是夹在0到1之间的值。当t是0时返回颜色a。当t是1时返回颜色b。
