Can someone explain the correct way to change my colors using c# in this shader. The error i get is…
MissingComponentException: There is no 'Renderer' attached to the "ProgressBar" game object, but a script is trying to access it.
You probably need to add a Renderer to the game object "ProgressBar". Or your script needs to check if the component is attached before using it.
UnityEngine.Renderer.get_material ()
ProgressBar Shader
The first line is the error above
Material yourGradientMaterial = canvasPlayers.GetChild(x).GetChild(0).GetComponent<Renderer>().material;
yourGradientMaterial.SetColor("_Color", Color.red); // the left color
yourGradientMaterial.SetColor("_Color2", Color.white); // the right color
child(x) = User1
child(0) = ProgressBar