Class ProgressBar
Class manage display of a progress bar. Animates over AnimationTime duration by filling a sprite from 0 to 100% width. Optionally, based on Text being null or disabled, will also update a TMPro.TextMeshProUGUI with the progress.
Inheritance
Namespace: LlamaSoftware.UI
Assembly: LlamaSoftware.UI.dll
Syntax
[DisallowMultipleComponent]
public class ProgressBar : MonoBehaviour
Fields
AnimationTime
How long the animation should play in seconds
Declaration
public float AnimationTime
Field Value
| Type | Description |
|---|---|
| System.Single |
DecimalsToShow
Maximum number of decimals to display. Only used if Text is provided.
Declaration
public int DecimalsToShow
Field Value
| Type | Description |
|---|---|
| System.Int32 |
EndTime
Declaration
protected float EndTime
Field Value
| Type | Description |
|---|---|
| System.Single |
FillClockwise
Whether or not to fill clockwise. Applied to ProgressBarImage on Awake().
Declaration
public bool FillClockwise
Field Value
| Type | Description |
|---|---|
| System.Boolean |
FillMethod
Fill method of the image. Forced on Awake().
Declaration
public Image.FillMethod FillMethod
Field Value
| Type | Description |
|---|---|
| UnityEngine.UI.Image.FillMethod |
FillOrigin
The Fill Method. Can be UnityEngine.UI.Image.Origin180, UnityEngine.UI.Image.Origin360, UnityEngine.UI.Image.Origin90, UnityEngine.UI.Image.OriginHorizontal, or UnityEngine.UI.Image.OriginVertical. Applied to ProgressBarImage on Awake().
Declaration
public int FillOrigin
Field Value
| Type | Description |
|---|---|
| System.Int32 |
i
Declaration
protected int i
Field Value
| Type | Description |
|---|---|
| System.Int32 |
OnCompleted
Action to call when progress bar completes animating
Declaration
public UnityEvent OnCompleted
Field Value
| Type | Description |
|---|---|
| UnityEngine.Events.UnityEvent |
OutOfRangeProgressMessage
Declaration
protected string OutOfRangeProgressMessage
Field Value
| Type | Description |
|---|---|
| System.String |
Prefix
Prefix to prepend to the provided percent. Only used if Text is provided.
Declaration
public string Prefix
Field Value
| Type | Description |
|---|---|
| System.String |
ProgressBarImage
The Filled Image that represents the progress
Declaration
public Image ProgressBarImage
Field Value
| Type | Description |
|---|---|
| UnityEngine.UI.Image |
ShowAsDecimal
If percent should be displayed as 0.85 or 85. Only used if Text is provided.
Declaration
public bool ShowAsDecimal
Field Value
| Type | Description |
|---|---|
| System.Boolean |
startingProgress
Declaration
protected float startingProgress
Field Value
| Type | Description |
|---|---|
| System.Single |
Suffix
Suffix to append to the provided percent. Only used if Text is provided.
Declaration
public string Suffix
Field Value
| Type | Description |
|---|---|
| System.String |
targetProgress
Declaration
protected float targetProgress
Field Value
| Type | Description |
|---|---|
| System.Single |
Text
Optional Text to update. If provided Suffix, Prefix, ShowAsDecimal, DecimalsToShow, and LlamaSoftware.UI.ProgressBar.DecimalDisplayFormat will be taken into consideration.
Declaration
public TextMeshProUGUI Text
Field Value
| Type | Description |
|---|---|
| TMPro.TextMeshProUGUI |
Properties
Progress
Read-only convenience property. Will always be the same as
Declaration
public float Progress { get; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Methods
AnimateProgress()
Coroutine to animate progress and update text. Do not call directly. Called in SimpleProgressBar.
Declaration
protected virtual IEnumerator AnimateProgress()
Returns
| Type | Description |
|---|---|
| System.Collections.IEnumerator | Coroutine |
Awake()
Forces ProgressBarImage to match
Declaration
protected virtual void Awake()
Reset()
Resets the progress bar to 0 fill immediately
Declaration
public virtual void Reset()
SetProgress(Single)
Animate the progress bar from current fill to the provided Progress. Also updates the text.
Declaration
public virtual void SetProgress(float Progress)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | Progress | 0-1 value representing the percent to fill the progress bar |
SetProgressImmediate(Single)
Immediately set the progress bar to the provided Progress (no animation)
Declaration
public virtual void SetProgressImmediate(float Progress)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | Progress | 0-1 value representing the percent to fill the progress bar |
SetText()
Declaration
protected virtual void SetText()
StopAnimation()
Stops the animation at the current progress
Declaration
public virtual void StopAnimation()