Button
Add a button the user can interact with to trigger an action.
Read time 2 minutesLast updated 13 days ago
A Button is an interactive element that users can click to perform an action, such as start an animation or interact with an object in the scene. A Button contains a parent Button object and a child Text object (where you set the button's label).
Button properties
The following properties are available for you to customize in the button's Inspector panel:Property | Description |
|---|---|
| Interactable | Set whether the user can interact with the button. |
| Normal | Choose the color for the button in its original state before anyone interacts with it. |
| Highlighted | Set the color for when the user's mouse hovers over the button. |
| Pressed | Pick the color shown while the user presses the button. The color remains until the user releases the button. |
| Selected | Choose the color shown after the user clicks and releases the button, which indicates the button was previously interacted with. |
| Disabled | Set the color for when the button can't be interacted with. |
| Fade Duration | Adjust the fade duration for color changes. |
| When button is clicked | This section lets you add animations that you can control via button interactions. Select Add (+) to add animations. |
| Add (+) | Add animations that the button interactions control. |
Button animation properties
The following options are available when you select Add (+) under When button is clicked:Property | Description |
|---|---|
| GameObject | Select the GameObject you want to animate. Make sure the object has an Animation component with an assigned animation clip. |
| Action | Select what you want the animation to do when the user clicks the button:
|
| Name | Choose the animation clip you want to control via button clicks. |
| Speed | Change how fast or slow the animation clip plays. Set to 1 for its original speed, between 0-1 to play slower, and higher than 1 to play it faster. |
Trigger button animations
You can set a button to trigger an animation in your scene:- Enable Interactable.
- Navigate to the When button is clicked section of the button's properties.
- Select Add (+) to add an animation section to your button.
- Expand the dropdown and select the object you want to animate.
- Choose an action (Play, Pause, Stop).
- If shown, set Name to the animation clip you want to trigger.