Documentation

Support

Unity Studio

Open Unity Studio

Unity Studio

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

InteractableSet whether the user can interact with the button.
NormalChoose the color for the button in its original state before anyone interacts with it.
HighlightedSet the color for when the user's mouse hovers over the button.
PressedPick the color shown while the user presses the button. The color remains until the user releases the button.
SelectedChoose the color shown after the user clicks and releases the button, which indicates the button was previously interacted with.
DisabledSet the color for when the button can't be interacted with.
Fade DurationAdjust the fade duration for color changes.
When button is clickedThis 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

GameObjectSelect the GameObject you want to animate. Make sure the object has an Animation component with an assigned animation clip.
ActionSelect what you want the animation to do when the user clicks the button:
  • Play: Play a specific animation on this object.
  • Pause: Pause all animations on this object.
  • Pause Specific: Pause a specific animation clip on this object.
  • Stop: Stop all animation clips on this object.
  • Stop Specific: Stop a specific animation clip on this object.
NameChoose the animation clip you want to control via button clicks.
SpeedChange 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:
  1. Enable Interactable.
  2. Navigate to the When button is clicked section of the button's properties.
  3. Select Add (+) to add an animation section to your button.
  4. Expand the dropdown and select the object you want to animate.
  5. Choose an action (Play, Pause, Stop).
  6. If shown, set Name to the animation clip you want to trigger.

Additional resources