Besides that you should cache the Renderer component so you do not need to look it up each frame the code should work.
Make sure you have a shader that support Transparency via the Main color.
The Unity Unlit shader do not have a variant with A texture + Transparency via the color attribute.
This shader from the unity wiki should work fine for you.
Shader "Unlit/UnlitAlphaWithFade"
{
Properties
{
_Color ("Color Tint", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Alpha (A)", 2D) = "white"
}
Category
{
Lighting Off
ZWrite Off
//ZWrite On // uncomment if you have problems like the sprite disappear in some rotations.
Cull back
Blend SrcAlpha OneMinusSrcAlpha
//AlphaTest Greater 0.001 // uncomment if you have problems like the sprites or 3d text have white quads instead of alpha pixels.
Tags {Queue=Transparent}
SubShader
{
Pass
{
SetTexture [_MainTex]
{
ConstantColor [_Color]
Combine Texture * constant
}
}
}
}
}
Hmm, tried it out, but will have to either keep looking, or learn more about shaders (so handy, yet my weakest skill when it comes to all of this…); the problem is that my icon is a .png with alpha layer/color, so that needs to be transparent (in addition to being able to change the overall alpha); doesn’t seem to work that way with the above shader
Maybe if I research enough about shader programming I can make it work (I hope)