---
title: Buttons
product: Unity Spark
canonical: https://docs.unity.com/en-us/unity-spark/create/build/ui-editor/elements/buttons
last_updated: 2026-12-01
generated_at: 2026-12-01T21:04:49.068Z
locale: en-us
---

# Buttons

> Add buttons to your Unity Spark UI.

A button is an element that the player selects to start an action, such as **Play**, **Pause**, or **Restart**. Players click it with a mouse, or tap it on a touch screen.

## Add buttons

To add a button to your UI:

1. Select a UI element in the **Hierarchy window** to open the **UI Editor**.
2. Select **Button** in the **UI Editor**'s lower toolbar.
3. Click the canvas to place the button, or drag on the canvas to draw it at the size you want.

Alternatively, in the **Hierarchy window**, select **Add object** (**+**) > **UI** > **Button**.

## Change button labels and roles

A new button is a shape with the **Primary Button** style role, and a **Text** element inside it.

To change the label:

1. Select the text inside the button.
2. Change its **Text**.

For a less prominent button, such as **Cancel**, change the button's **Role** to **Secondary Button**.

## Button settings

The **Button** [component](/unity-spark/create/build/components/about-components.md) contains the following settings.

| **Setting**        | **Description**                                                                              |
| :----------------- | :------------------------------------------------------------------------------------------- |
| **Target Graphic** | Sets the part of the button that changes color when the player hovers over it or selects it. |

To make any shape behave like a button, add a **Button** component to it.

Buttons, sliders, toggles, input fields, and scrollbars share the following settings.

| **Setting**      | **Description**                                                                                                                                                                                                                                                     |
| :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Interactable** | Sets whether the player can use the control. When **Interactable** is disabled, the control shows its **Disabled Color**.                                                                                                                                           |
| **Colors**       | Sets the tint for each state: **Normal Color**, **Highlighted Color** (when the pointer is over it), **Pressed Color**, **Selected Color**, and **Disabled Color**. **Color Multiplier** brightens every state, and **Fade Duration** sets how long a change takes. |

## Respond to button clicks

A button does something only when your game responds to it. The [Inspector window](/unity-spark/create/build/components/inspector-window-reference.md) doesn't have a list of click actions, so use the [AI assistant](/unity-spark/create/assistant/about-assistant.md) or a script.

To use the assistant, describe what the button does, for example, `When the player clicks Restart, reload the current scene.` For more examples, refer to [Add button behaviors and create screens with the assistant](/unity-spark/create/build/ui-editor/ui-assistant.md).

To respond to a click in a script, pass a function to the button's `OnClick`.

```lua
local function onRestart()
  -- what happens when the player clicks the button
end

restartButton:OnClick(onRestart)
```

Pass a function that you define in the same script. Don't pass `self`, because the event calls the function you give it.

## Additional resources

* [Introduction to UI elements](/unity-spark/create/build/ui-editor/elements/about-ui-elements.md)
* [Add button behaviors and create screens with the assistant](/unity-spark/create/build/ui-editor/ui-assistant.md)
* [Write and attach scripts](/unity-spark/create/build/scripts/write-scripts.md)
