Change Alpha of a gameObject material

I have a game object which I have added a particle/alpha blend material to.

I am trying to fade the alpha in and out by grabbing the colour and lerping the alpha.

I am trying to access the color with the following code :
Color color = gameObject.renderer.material.color;

However, when I try to access the color I get the following error.

Material doesn’t have a color property ‘_Color’

The particle/alpha blend material does have a tint color, so I’m a bit confused. Can someone point me in the right direction?

Thanks

renderer.material.color is just a shortcut to renderer.material.GetColor("_Color") - i.e. the main “Color” property of a material. However, as you’ve noticed (and as the error message also states) the Particle/AlphaBlend shader doesn’t have a _Color - it only has a _TintColor.

So, to access the _TintColor property, you want to use:

Color color = renderer.material.GetColor("_TintColor");

(and, to change the value, use SetColor)