"renderer.material.color" not working

I am trying to change the color tint of one sprite in this way:

sprite.renderer.material.color=Color.red;

But it is not working and the sprite remains in his original material color (white).
The shader is the standard particle/alpha blended and when changed the material color in the Inspector it is showed correctly…

However when I use:

sprite.renderer.enabled=false

it does work and the sprite “dissapear” like expected.

???

EDITED.

What shader are you using? Only shaders that utilize a property named _Color will do anything.

The shader is the standard particle/alpha blended and when changed the material color in the Inspector it is showed correctly.

That shader doesn’t have a _Color property, which is why “material.color = Color.red” doesn’t work, since that’s a shortcut for “material.SetColor (”_Color", Color.red)". If you look in the shader, you can see they used _TintColor instead. (Which is a bit arbitrary if you ask me.)

–Eric

Is there any solution?
Thanks anyway.

Yes, as I mentioned, “material.color = Color.red” is a shortcut for “material.SetColor (”_Color", Color.red)". The particle/alpha blended shader uses _TintColor rather than _Color. I’m sure you can figure it out from here. :slight_smile:

–Eric

Yes, I had tried that before asking the last time but I forgot to include the quotation marks in “_TintColor” and I got an error, and I thought it was not so easy to fix, Thanks. :slight_smile:

I would edit the shader and report a bug. The faster they fix it, the better. Otherwise, it’s going to be broken forever.