function Update () {
var lerp = Mathf.PingPong (Time.time, duration) / duration;
renderer.material.color = Color.Lerp (colorStart, colorEnd, lerp);
}
from the refrence which works great for changing the color. But how can I get it to also change the opacity of the object. I want to fade it away. How do I effect the alpha channel. I have been trying something like this
Most shaders do not alpha blend. Use a shader from the "Transparent" section.
Edit: The shader you're using doesn't work, because the alpha of the color is not preserved when using lighting. Fortunately, you don't need lighting at all. Here's a shader that will work:
That may have worked in some version of Unity, but in 4.3, I get a compile-time error (Cannot modify a value type return value of `UnityEngine.Material.color’).