Introduction to UI elements
Understand what each Unity Spark UI element is for, how UI styles give elements their appearance, and how your game responds when players use them.
Read time 3 minutesLast updated 3 hours ago
UI elements are the parts of your game's interface that sit on top of the game world, such as a score, a health bar, a pause button, or a settings menu. You add them from the toolbar of the UI Editor. For more information about adding elements, refer to Add and style UI elements.
Choose an element
Use the following table to choose the element for what you want to show or let players do.
Element | Description | Examples |
|---|---|---|
| Text | Words on the screen. | Titles, labels, scores, and messages. |
| Image | A picture from your project. | Logos, portraits, and backgrounds. |
| Icon | A ready-made symbol from a built-in set. | Hearts, coins, arrows, and other small symbols. |
| Shape | A rectangle with rounded corners, borders, and shadows that needs no art. | Panels, cards, frames, and backgrounds. |
| Button | An element the player selects to start an action. | Play, Pause, Restart, and menu choices. |
| Slider | A handle the player drags along a track to choose a value in a range. | Volume, brightness, and difficulty. |
| Toggle | A checkbox the player turns on or off. | Settings such as music on or off. |
| Dropdown | A list that opens so the player can pick one option. | Choosing a level, a language, or a quality setting. |
| Input Field | A box the player types into. | Entering a puzzle answer or a code. |
| Progress Bar | A bar that fills to show how much of something there is. | Health, loading, and timers. |
| Scroll View | An area that scrolls to show more content than fits. | Long lists, such as an inventory or a level list. |
| Scrollbar | A bar the player drags to scroll. | Scrolling a scroll view, or any value from start to end. |
Elements are placed on a canvas. If your scene has no canvas, Unity Spark adds one with the first element. For more information about canvases, refer to Introduction to game UI.
Element styles and style roles
Most elements take their colors, fonts, corners, and shadows from your UI style, so your whole interface is consistent. Each part of an element has a style role, such as Primary Button, Panel, or Heading, which decides which part of the style it uses. When you change the UI style, every element with a role updates.
A Style Role component on each part sets the part's role. You can change a part's role, or detach an element from the style to style it by hand. A detached element keeps its current styling, and style changes no longer affect it.
For more information about choosing a UI style, changing roles, and detaching elements, refer to Give your UI a style.
Make elements work
Elements such as buttons and sliders do something only when your game responds to them. For example, a Play button needs to start the game when the player selects it, and a volume slider needs to change the volume when the player drags it.
To make elements work, ask the AI assistant with prompts such as the following:
When the player clicks Play, load the Level 1 scene.Make the volume slider change the music volume.Update the score text whenever the player collects a coin.
You can also respond to elements in your own scripts. Each element page shows the script events and values to use. For more information about scripts, refer to Scripts.