I’m using material.lerp to change smoothly change a gameobject color from material1 to material2.
The code from the reference document is:
// 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 = Mathf.PingPong (Time.time, duration) / duration;
renderer.material.Lerp (material1, material2, lerp);
}
Is there anyway to use the y-coordinate of the mesh so the transition gradually moves up the gameobject, or would this require writing a shader?
Thank you.