Changing color in in runtime to a cube
Hello everybody, my issue is the following. I have a cube with a material of green color associated. The material has a standard shader associated as well with a pale green albedo. Here's a picture
I need to change its color during runtime so I tried
getComponent<MeshRenderer>.material.color=Color.red
But the color didn't change at all. So I tried to completely swap to a different material doing:
Material[] curr_materials = cube_StartPhase.transform.GetComponent<MeshRenderer>().materials;
curr_materials[0] = button_material[1];
cube_StartPhase.transform.GetComponent<MeshRenderer>().materials = curr_materials;
where button_material is a vector of size 2 with a green material in position 0 and a red material in position 1 that i have loaded using Resources.Load(....) as Material
. However also in this way I don't get the expected red but a paler pinkish version and when I try, from that color, to move back to green again using a code similar to the one above, the cube becomes purple instead of goinf back to the original green. Can somebody help me to solve this issue? I think it's a problem with the shader but I have no idea how to fix it.