Logo
UI Elements

Progress Bar

A flexible progress bar with smoothing

Overview

Progress Bar displays a numeric value between a minimum and maximum range and visually represents the percentage using a UI bar. It supports horizontal and vertical fill directions, number formatting, text prefixes, animation smoothing, and both Image fill mode and RectTransform anchor filling.

The component updates its text and fill amount whenever the value changes, and can animate toward its target smoothly using an easing curve.

This is ideal for loading bars, HP bars, XP bars, crafting progress, ability cooldowns, or any UI where a numeric range should be displayed.


Properties

Value

NameTypeDescription
ValuefloatCurrent value (clamped between MinValue and MaxValue)
MinValuefloatMinimum limit
MaxValuefloatMaximum limit

Settings

NameTypeDescription
invokeAtStartboolInvokes onValueChanged on Start
isVerticalboolUses vertical fill instead of horizontal
displayMultiplierfloatMultiplier applied before displaying text
displayFormatDisplayFormatFixed or thousands number formatting
textFormatstringFormat containing 0 placeholder

Animation

NameTypeDescription
enableSmoothingboolEnables animated transitions
smoothingDurationfloatDuration of smoothing animation
smoothingCurveAnimationCurveEasing for smoothed transitions

References

NameTypeDescription
fillRectRectTransformRectTransform or Image used to visually represent progress
valueTextTMP_TextOptional text display for the current value

Events

NameTypeDescription
onValueChangedUnityEvent<float>Fired when Value changes

Public Methods

NameParametersDescription
SetValue(newValue)floatSets a new value and optionally animates
SetValueInstant(newValue)floatSets value immediately without smoothing
SetValueWithoutNotify(newValue)floatUpdates visually without triggering onValueChanged
GetFormatString()NoneReturns format string used internally
FormatValue(value)floatReturns formatted text for a value

Code Example

ProgressBarExample.cs
using UnityEngine;
using Evo.UI;

public class ProgressBarExample : MonoBehaviour
{
    public ProgressBar bar;

    void Start()
    {
        // Set values instantly
        bar.MinValue = 0;
        bar.MaxValue = 200;
        bar.SetValueInstant(50);

        // Animate to new value
        bar.SetValue(150);

        // With multiplier and custom text
        bar.displayMultiplier = 100;
        bar.textFormat = "{0}%";

        // Hook event
        bar.onValueChanged.AddListener(v =>
        {
            Debug.Log("Progress updated: " + v);
        });
    }

    void Update()
    {
        // Example: animate from 0 to max
        if (Input.GetKeyDown(KeyCode.Space))
        {
            bar.SetValue(200);
        }
    }
}

On this page