How to Change Button Color Based on Interactivity in Unity

 



In Unity Editor, you can change the color of a Button when it's interactable and non-interactable by adjusting its colors through the Unity Inspector. Follow these steps:


Step 1: Select the Button GameObject


Select the Button: In the Unity Editor, click on the Button GameObject.





Step 2: Adjust the Colors in the Inspector


1- Button Component: In the Inspector panel, find the Button component.


2- Colors Section: The Button component has a section called "Colors". This section contains properties for different states of the button: Normal, Highlighted, Pressed, Selected, and Disabled.



    • Normal Color: This is the color of the button when it's in its default state.
    • Highlighted Color: This is the color of the button when the mouse hovers over it.
    • Pressed Color: This is the color of the button when it's being clicked.
    • Selected Color: This is the color of the button when it's selected (this might not be applicable for all cases).
    • Disabled Color: This is the color of the button when it's non-interactable.





3- Changing Colors:


    • Click on the color box next to each state (e.g., Normal Color, Highlighted Color, etc.).
    • A color picker will appear. You can either pick a color from the palette or enter specific RGB values.
    • Once you've chosen the desired color, the button will change its color accordingly when in that state.



Step 3: Set Interactable Property


Interactable Property: Directly above the "Colors" section, you'll find the "Interactable" checkbox. If this checkbox is checked, the button is interactable. If it's unchecked, the button is non-interactable.


Step 4: Preview in the Scene View


Scene View: You can switch to the Scene View to see how your button looks in different states by selecting the GameObject and observing its appearance based on the defined colors.







⭐Happy coding⭐




Previous Post Next Post

Contact Form