I have a function where you click on an object and it changes the color and emission of a specific material, every object has multiple materials with different order.
var emissionColor = mat.GetColor("_EmissionColor");
List<Material> materials.AddRange(t.GetComponent<MeshRenderer>().materials);
foreach (var m in materials)
{
if (m.name.Equals(matName))
{
//Debug.Log(m.name);
m.EnableKeyword("_EMISSION");
m.color = mat.color;
m.SetColor("_EmissionColor", emissionColor);
}
}
So far I'm changing the color once but I would like to have it transition into a different color every 10 seconds, I tried using the animator but it keeps changing the wrong material. Is there a way to do this animation in code?