Transparent and colorized material with texture

Hello everyone,

I am trying to apply a material to my mesh. I want this material to have a texture with alpha and to be able to be colorized with something like this :

this.gameObject.renderer.material.color = Color.red;

Then every opaque pixel of the texture (with alpha = 1) will be colorized in red and the rest of the texture will stay transparent, according to its alpha (half opaque pixel would appear red and half visible and transparent pixels would appear transparent as usual).

I tried to achieve this with a material with a built-in Transparent/Diffuse shader but it doesn’t work. When I change the material color in a script, the color doesn’t change and every pixel keeps the color of the default texture applied.

Any ideas on how to do this ? Thank you.

I found the answer, thanks to this life saving topic. I needed a custom shader, as robertbu said and I found it already written on this topic.