SetColor not working?

Hi, I can’t get this code to work:

Color ccc = new Color(wall.renderer.material.color.r, wall.renderer.material.color.g, wall.renderer.material.color.b, acolor2);

wall.renderer.material.SetColor(“_MainColor”, ccc);

What I’m trying to do is to set the “Main Color”'s alpha-value to the “acolor2” value.

There are no errors, it just won’t change the alpha-value.

Thanks in advance.


Check out the documentation for SetColor. You are using “_MainColor”, but

“_Color” is the main color of a material. This can also be accessed via color property.