Hey,
I’m trying to make a transition between 2 materials, but I’m not having success as the example given in the documentation.
I need to change a material [Shader: Sprites / Default] to [Shader: Sprites / Diffuse], is it possible?
public class ChangeMaterial : MonoBehaviour {
public Material materialA;
public Material materialB;
public float duration = 2.0f;
void Update()
{
var sprite = GetComponent<SpriteRenderer>();
var lerp = Mathf.PingPong(Time.time, duration) / duration;
sprite.material.Lerp(materialA, materialB, lerp);
}
}
With this code nothing happens!
What could be wrong?
Every help is welcome!