标签:var new delay shader date material tco bool color
private float rotaSpeed = 5f;
private float timer = 1;
private bool flag = true;
private float delay = 4.0f;
void Update ()
{
if (timer <= 0)
{
flag = false;
}
if (flag == false)
{
timer += Time.deltaTime / delay;
}
if (timer >= 1)
{
flag = true;
}
if (flag == true)
{
timer -= Time.deltaTime / delay;
}
var render = Cube.GetComponent<Renderer>();
if (render != null)
{
var r = render.material.color.r;
var g = render.material.color.g;
var b = render.material.color.b;
render.material.color = new Color(r, g, b, timer);
}
//cube自转
Cube.transform.Rotate(new Vector3(0, -1, 0), Time.deltaTime * rotaSpeed);
}
改变Cube的Shader下的Alpha值,实现Cube若隐若现的效果。
标签:var new delay shader date material tco bool color
原文地址:http://www.cnblogs.com/Study088/p/7111272.html