Transparency not working at runtime

Hello

I want to control the transparency of an object at runtime.

I’m using a simple code to change the alpha channel of the object, but it does not work.

Everything works fine in the editor though, if i change the alpha through the editor it works fine.

Every other answer i found here were about using a Transparent/Diffuse shader and controlling tha alpha using a range from 0 to 1 via code, but i’m using this shader and the correct range already.

Have you ever experiencing anything like this?
Thanks in advance.

Where doesnt it work? The shader that your using may not be compatible with your device.

Color is a struct, so you get back a copy of the color, not a reference to it. To fix your problem, you have to assign the color back to the material:

Color color;

void Start() {
  color = renderer.material.color;
  color.a = 0.5f;
  render.material.color = color;
  }