# Changing Shader Properties From a Script in Unity ## Shader Properties > [!abstract] Documentation > Global properties are used if a shader needs them but the material does not have them defined (for example, if the shader does not expose them in `Properties` block). > > Usually this is used if you have a set of custom shaders that all use the same "global" color (for example, color of the sun). Then you can set the global property from script and don't have to setup the same color in all materials. > > [Documentation Source](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Shader.SetGlobalColor.html) ## Changing Shader Property Values Via C\# You can change the value of a property in a shader by setting it globally, but this only works if it's not defined in the material that's using it. Instead, you can use a reference to the given material to set the property directly. ```cs // This doesn't work because "_TintColor" is exposed as a // property in the material Shader.SetGlobalColor("_TintColor", BackboardCurrentColor); // This works because you're just setting a value on // the material's property directly ShaderMaterial.SetColor("_TintColor", BackboardCurrentColor); ``` #unity #c_sharp #shaders