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 inside it with the Bar Fill role. The fill shortens from one edge and keeps its rounded end.
FillTo change how full the bar is in the editor:
- Select .
Fill - In the Inspector window, expand the Progress section of the Shape component.
The Progress section contains the following settings.
Setting | Description |
|---|---|
| Fill Amount | Sets how full the bar is, from |
| Direction | Sets 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, You can also set the fill's 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.
Make the health bar show the player's health.fillAmountlocal fill = fillObject:GetComponent('Shape')Tween.to(fill, { fillAmount = math.clamp(health / maxHealth, 0, 1) }, 0.2, 'easeOutQuad')
Change , not the size of the fill. Resizing the fill squashes its rounded ends.
fillAmount