-
Notifications
You must be signed in to change notification settings - Fork 0
π Getting Started
Dennis edited this page Feb 2, 2025
·
6 revisions
- Select a UI component in Unity (e.g.,
Image,TextMeshProUGUI) - Open the
Inspectorpanel - Click
Add Componentand search forUIMaterialModifier
- Ensure the UI component's
Materialuses a shader that supports modification. - Example:
UI/Unlit/Transparent
You can modify properties directly in the Inspector:
-
Color (
_Color) -
Transparency (
_Alpha) -
Saturation (
_Saturation) -
Contrast (
_Contrast)
Or modify them via script:
using Dennis.UI;
CustomUI customUI = myGameObject.GetComponent<CustomUI>();
customUI.SetFloat("_Saturation", 1.5f);
customUI.SetColor("_Color", Color.red);If you enter a property name that does not exist in the shader, you will see a yellow warning in the Inspector:
Shader does not have property 'aaa'

1οΈβ£ Check the Shader Property Name
- Open the Material Inspector and find the exact property name.
- Ensure it starts with
_(e.g.,_Color,_Saturation).
2οΈβ£ Verify That the Shader Supports the Property
- Open the Shader Code (
.shaderfile) and check if the property exists. - Example:
_Saturation ("Saturation", Range(0, 2)) = 1
- If the shader does not define _Saturation, adding it in UIMaterialModifier will have no effect.
3οΈβ£ Use the Correct Property Type
| Property Name | Expected Type | Incorrect Type |
|---|---|---|
| _Color | Color | Float, Int |
| _Saturation | Float | Color, Vector4 |
If you select a shader property type that does not match the actual property type, you will see a yellow warning in the Inspector:
Shader property '_Color' is expected to be Color, but you assigned Float.

1οΈβ£ Check the Shader Property Type
- Click on the Material attached to your UI element.
- Find the shader property you want to modify.
- Verify its type in the shader code (e.g.,
_Colorshould beColor,_Saturationshould beFloat).
2οΈβ£ Select the Correct Type in the Inspector
-
If
_Coloris a Color, select Color from the dropdown. -
If
_Saturationis a Float, select Float from the dropdown.
3οΈβ£ Fix it in the Inspector
- β
Before (Wrong)
- Property Name: "_Color" Type: Float π¨ Warning: Shader property '_Color' is expected to be Color, but you assigned Float.
- β
After (Fixed)
- Property Name: "_Color" Type: Color β No Warning
- β Always check the shader property type before modifying it.
- β
Use
Inspector > Materialto confirm available properties. - β Only modify properties that exist in the shader.
- β Use a test material to verify property changes before applying them globally.
π¦ Installation | π Shader Property Support | π API Reference