I have three cubes (one in front of another) in a Unity scene and I would like it when a condition is given, the first cube would come out semi-transparent so that the one from the back could be seen.
I tried the following:
cubo1.GetComponent<Renderer>().material.color.a = 0.5f;
But I get an error. I have the cubes declared as follows:
public GameObject cubo1;
I changed the Material Shader from Standard
to Legacy Shaders/Transparent/Diffuse
for the Alpha channel theme, but nothing ...
Does anyone have any ideas?