Documentation

Unity Spark

Open Unity Spark

Unity Spark

Progress bars

Show health, loading progress, or a timer with the Progress Bar element in your Unity Spark UI, and change how full it is from a script.
Read time 1 minuteLast updated 3 hours ago

A progress bar shows a value as a bar that fills and empties, such as health, loading progress, or time left. Unlike a slider, a progress bar doesn't let the player drag it.

Set the bar fill

A new progress bar has two shapes: a dark track with the Bar Track style role, and a shape named
Fill
inside it with the Bar Fill role. The fill shortens from one edge and keeps its rounded end.
To change how full the bar is in the editor:
  1. Select
    Fill
    .
  2. In the Inspector window, expand the Progress section of the Shape component.
The Progress section contains the following settings.

Setting

Description

Fill AmountSets how full the bar is, from
0
(empty) to
1
(full).
DirectionSets which edge the bar fills from, for example, from left to right.

Update progress while the game runs

To show a value such as health, ask the AI assistant, for example,
Make the health bar show the player's health.
You can also set the fill's
fillAmount
in a script. To animate the change smoothly, use a tween, which changes a value gradually over a set time, as in the following example.
local fill = fillObject:GetComponent('Shape')Tween.to(fill, { fillAmount = math.clamp(health / maxHealth, 0, 1) }, 0.2, 'easeOutQuad')
Change
fillAmount
, not the size of the fill. Resizing the fill squashes its rounded ends.

Additional resources