Search Results for

    Show / Hide Table of Contents

    Class ProgressBar

    The progress bar inherits from the ValueManager to modify the minimum, current and maximum values during runtime.
    The visual appearance and functionality are divided into different simple C# classes :

    • ProgressBarText : Updates the text of the current value and maximum value of the progress bar.
    • Indicator : Maintains the position of a Sprite at the current value of the progress bar.
    • Borders : Add borders to each corner of the progress bar : Top, Bottom, Left, Right.
    • ProgressBarRegeneration : Updates the text of the current regeneration applied to the progress bar.
    • AnimationsManager : Controls the shaking and pulsing animations.
    Inheritance
    object
    ValueManager
    ProgressBar
    Implements
    IColorChanger
    Inherited Members
    ValueManager._initialValue
    ValueManager._initialMaximum
    ValueManager._initialMinimum
    ValueManager._precisionTolerance
    ValueManager._allowValueIncrease
    ValueManager._allowValueDecrease
    ValueManager._minimum
    ValueManager._maximum
    ValueManager._value
    ValueManager._initialized
    ValueManager._valueState
    ValueManager._initialAllowValueIncrease
    ValueManager._initialAllowValueDecrease
    ValueManager.InitializedEvent
    ValueManager.ValueChangedEvent
    ValueManager.ValueStateChangedEvent
    ValueManager.MaximumValueReachedEvent
    ValueManager.MinimumValueReachedEvent
    ValueManager.ValuesRestoredEvent
    ValueManager.Initialized
    ValueManager.ValueState
    ValueManager.PrecisionTolerance
    ValueManager.AllowValueIncrease
    ValueManager.AllowValueDecrease
    ValueManager.AllowChanges
    ValueManager.Minimum
    ValueManager.Maximum
    ValueManager.Value
    ValueManager.Percentage
    ValueManager.MissingValue
    ValueManager.MissingValuePercentage
    ValueManager.CurrentState
    ValueManager.AtMaximum
    ValueManager.AtMinimum
    ValueManager.LastValueChange
    ValueManager.LastMaximumValueChange
    ValueManager.LastMinimumValueChange
    ValueManager.LastOverflowAmount
    ValueManager.MaximumAmountWithinLimits
    ValueManager.Initialize()
    ValueManager.CanDecrease()
    ValueManager.CanIncrease()
    ValueManager.Increase(float)
    ValueManager.Decrease(float)
    ValueManager.IncreaseMaximum(float)
    ValueManager.DecreaseMaximum(float)
    ValueManager.IncreaseMinimum(float)
    ValueManager.DecreaseMinimum(float)
    ValueManager.SetToMinimum()
    ValueManager.SetToMaximum()
    ValueManager.SetByPercentage(float)
    ValueManager.GetLastChangeOf(ValueType)
    ValueManager.RestoreValues()
    ValueManager.SetInitialValues(float, float, float, bool)
    ValueManager.AreEqual(float, float)
    ValueManager.ToString()
    ValueManager.InitializeValues()
    ValueManager.SetValue(float)
    ValueManager.SetLastChange(float, ValueType)
    ValueManager.RaiseLimitReachedEvents()
    ValueManager.UpdateValueState()
    ValueManager.SetMinimum(float)
    ValueManager.SetMaximum(float)
    ValueManager.GetClampedValue(float)
    ValueManager.SetLastOverflow(float)
    ValueManager.OnValueStateChanged()
    ValueManager.OnMaximumValueReached()
    ValueManager.OnMinimumValueReached()
    ValueManager.OnValuesRestored()
    Namespace: TetraCreations.ProgressBarSystem
    Assembly: cs.temp.dll.dll
    Syntax
    public class ProgressBar : ValueManager, IColorChanger

    Fields

    _activeCondition

    Declaration
    protected ProgressBarCondition _activeCondition
    Field Value
    Type Description
    ProgressBarCondition

    _animations

    Declaration
    protected AnimationsManager _animations
    Field Value
    Type Description
    AnimationsManager

    _backgroundImage

    Declaration
    protected Image _backgroundImage
    Field Value
    Type Description
    Image

    _backgroundInitialColor

    Declaration
    protected Color _backgroundInitialColor
    Field Value
    Type Description
    Color

    _backgroundRectTransform

    Declaration
    protected RectTransform _backgroundRectTransform
    Field Value
    Type Description
    RectTransform

    _backgroundSprite

    Declaration
    protected Sprite _backgroundSprite
    Field Value
    Type Description
    Sprite

    _borders

    Declaration
    protected Borders _borders
    Field Value
    Type Description
    Borders

    _bordersInitialColor

    Declaration
    protected Color _bordersInitialColor
    Field Value
    Type Description
    Color

    _canvasGroup

    Declaration
    protected CanvasGroup _canvasGroup
    Field Value
    Type Description
    CanvasGroup

    _conditions

    Declaration
    protected List<ProgressBarCondition> _conditions
    Field Value
    Type Description
    List<><ProgressBarCondition>

    _decreaseSegmentImage

    Declaration
    protected Image _decreaseSegmentImage
    Field Value
    Type Description
    Image

    _decreaseSegmentInitialColor

    Declaration
    protected Color _decreaseSegmentInitialColor
    Field Value
    Type Description
    Color

    _fillSegmentCurrentColor

    Declaration
    protected Color _fillSegmentCurrentColor
    Field Value
    Type Description
    Color

    _fillSegmentImage

    Declaration
    protected Image _fillSegmentImage
    Field Value
    Type Description
    Image

    _fillSegmentInitialColor

    Declaration
    protected Color _fillSegmentInitialColor
    Field Value
    Type Description
    Color

    _icon

    Declaration
    protected Sprite _icon
    Field Value
    Type Description
    Sprite

    _iconImage

    Declaration
    protected Image _iconImage
    Field Value
    Type Description
    Image

    _increaseSegmentImage

    Declaration
    protected Image _increaseSegmentImage
    Field Value
    Type Description
    Image

    _increaseSegmentInitialColor

    Declaration
    protected Color _increaseSegmentInitialColor
    Field Value
    Type Description
    Color

    _indicator

    Declaration
    protected Indicator _indicator
    Field Value
    Type Description
    Indicator

    _indicatorInitialColor

    Declaration
    protected Color _indicatorInitialColor
    Field Value
    Type Description
    Color

    _progressBarText

    Declaration
    protected ProgressBarText _progressBarText
    Field Value
    Type Description
    ProgressBarText

    _rectTransform

    Declaration
    protected RectTransform _rectTransform
    Field Value
    Type Description
    RectTransform

    _regeneration

    Declaration
    protected Regeneration _regeneration
    Field Value
    Type Description
    Regeneration

    _regenerationText

    Declaration
    protected ProgressBarRegenerationText _regenerationText
    Field Value
    Type Description
    ProgressBarRegenerationText

    _resource

    Declaration
    protected Resource _resource
    Field Value
    Type Description
    Resource

    _runtimeConditions

    Declaration
    protected List<ProgressBarCondition> _runtimeConditions
    Field Value
    Type Description
    List<><ProgressBarCondition>

    _segmentController

    Declaration
    protected SegmentController _segmentController
    Field Value
    Type Description
    SegmentController

    Properties

    ActiveCondition

    Currently active condition.

    Declaration
    public ProgressBarCondition ActiveCondition { get; protected set; }
    Property Value
    Type Description
    ProgressBarCondition

    Animations

    Controls the Shake and Pulsing Effect animations.

    Declaration
    public AnimationsManager Animations { get; protected set; }
    Property Value
    Type Description
    AnimationsManager

    BackgroundColor

    Current color of the backgound.

    Declaration
    public Color BackgroundColor { get; set; }
    Property Value
    Type Description
    Color

    BackgroundRectTransform

    Reference of the Progress Bar background RectTransform.

    Declaration
    public RectTransform BackgroundRectTransform { get; protected set; }
    Property Value
    Type Description
    RectTransform

    Borders

    Controls the Width of the Background and all the Segments image to show a Border.

    Declaration
    public Borders Borders { get; protected set; }
    Property Value
    Type Description
    Borders

    CanvasGroup

    Used to Show/Hide the Progress Bar.

    Declaration
    public CanvasGroup CanvasGroup { get; protected set; }
    Property Value
    Type Description
    CanvasGroup

    ColorChangedEvent

    When the color of the FillSegment changes, other scripts such as PulseImageEffect must update their cached value.

    Declaration
    public EventHandler<ColorChangedEventArgs> ColorChangedEvent { get; set; }
    Property Value
    Type Description
    System.EventHandler<TEventArgs><ColorChangedEventArgs>

    Conditions

    List of all the possible conditions that can be met at runtime, theses scriptable objects are instantiated during initialization.

    Declaration
    public List<ProgressBarCondition> Conditions { get; protected set; }
    Property Value
    Type Description
    List<><ProgressBarCondition>

    CurrentColor

    The Color of the Fill Segment

    Declaration
    public Color CurrentColor { get; }
    Property Value
    Type Description
    Color

    DecreaseSegmentColor

    Current color of the Decrease Segment.

    Declaration
    public Color DecreaseSegmentColor { get; set; }
    Property Value
    Type Description
    Color

    FillSegmentColor

    Current color of the Fill Segment.

    Declaration
    public Color FillSegmentColor { get; set; }
    Property Value
    Type Description
    Color

    HasActiveCondition

    Determines if their is a condition being applied to the Progress bar.

    Declaration
    public bool HasActiveCondition { get; }
    Property Value
    Type Description
    bool

    Icon

    Get / Set the Icon Sprite.

    Declaration
    public Sprite Icon { get; set; }
    Property Value
    Type Description
    Sprite

    IconColor

    Current color of the Icon.

    Declaration
    public Color IconColor { get; set; }
    Property Value
    Type Description
    Color

    IconImage

    Get the Icon Image Component

    Declaration
    public Image IconImage { get; }
    Property Value
    Type Description
    Image

    IncreaseSegmentColor

    Current color of the Increase Segment.

    Declaration
    public Color IncreaseSegmentColor { get; set; }
    Property Value
    Type Description
    Color

    Indicator

    Small icon indicating the current value position on the Progress Bar.

    Declaration
    public Indicator Indicator { get; protected set; }
    Property Value
    Type Description
    Indicator

    IndicatorColor

    Current color of the Indicator.

    Declaration
    public Color IndicatorColor { get; set; }
    Property Value
    Type Description
    Color

    IsVisible

    Determines if the Progress Bar is currently visible.

    Declaration
    public bool IsVisible { get; }
    Property Value
    Type Description
    bool

    RectTransform

    Reference of the Progress Bar RectTransform.

    Declaration
    public RectTransform RectTransform { get; protected set; }
    Property Value
    Type Description
    RectTransform

    Regeneration

    Regeneration component of the Progress Bar.

    Declaration
    public Regeneration Regeneration { get; protected set; }
    Property Value
    Type Description
    Regeneration

    RegenerationText

    Updates the regeneration text values of the Progress Bar.

    Declaration
    public ProgressBarRegenerationText RegenerationText { get; protected set; }
    Property Value
    Type Description
    ProgressBarRegenerationText

    Resource

    Used to know what the Progress Bar represent : Health, Armor, Mana, Experience etc.

    Declaration
    public Resource Resource { get; set; }
    Property Value
    Type Description
    Resource

    RuntimeConditions

    Read Only list of _runtimeConditions.

    Declaration
    public IReadOnlyList<ProgressBarCondition> RuntimeConditions { get; }
    Property Value
    Type Description
    IReadOnlyList<><ProgressBarCondition>

    SegmentController

    Controls the fill amount of each segments : Main, Increase, Decrease.

    Declaration
    public SegmentController SegmentController { get; protected set; }
    Property Value
    Type Description
    SegmentController

    Text

    Manage all the text values to display.

    Declaration
    public ProgressBarText Text { get; protected set; }
    Property Value
    Type Description
    ProgressBarText

    VisibleIcon

    Enable / Disable the Image component of the Icon.

    Declaration
    protected bool VisibleIcon { get; set; }
    Property Value
    Type Description
    bool

    Methods

    AnyConditionMet()

    Loop through all ProgressBarConditions to check whether or not they have been met.
    Only one condition can be active, so the order of the conditions matters.
    The most important condition should be the first in the list.
    When a condition is applied it keeps all the colors in cache, to undo the changes if it is removed.

    Declaration
    protected virtual void AnyConditionMet()

    Hide()

    Hide the health bar using the CanvasGroup.

    Declaration
    public void Hide()

    Initialize(float, float, float, Resource)

    Initialize the bar with default values, add listeners to events and update the text.

    Declaration
    public virtual bool Initialize(float currentValue, float maximumValue, float minimumValue = 0, Resource resource = null)
    Parameters
    Type Name Description
    float currentValue

    The starting value

    float maximumValue

    Maximum value

    float minimumValue

    Minimum value, default 0f.

    Resource resource

    What type of resource the ProgressBar represent

    Returns
    Type Description
    bool

    InitializeClasses()

    Initialize all other classes using the ProgressBar instance.
    Set the SegmentController as listener of the ValueChangedEvent to update the fill amount of each segments.

    Declaration
    protected virtual void InitializeClasses()

    IsValid()

    Determines if some references are missing which prevents the Progress Bar from initializing.

    Declaration
    public virtual bool IsValid()
    Returns
    Type Description
    bool

    OnActiveConditionChanged()

    Raise the ActiveConditionChangedEvent and pass the ActiveCondition inside ActiveConditionChangedEventArgs.

    Declaration
    protected virtual void OnActiveConditionChanged()

    OnFillSegmentColorChanged()

    Raise the ColorChangedEvent and pass the FillSegmentColor inside ColorChangedEventArgs.

    Declaration
    protected virtual void OnFillSegmentColorChanged()

    OnInitialized()

    Raise InitializedEvent from ValueManager then rasie the ProgressBarInitializedEvent.

    Declaration
    protected override void OnInitialized()
    Overrides
    ValueManager.OnInitialized()

    OnValueChanged(float, ValueType)

    Calls base.OnValueChanged to raise ValueChangedEvent; checks if any condition is met.

    Declaration
    protected override void OnValueChanged(float newValue, ValueType valueType)
    Parameters
    Type Name Description
    float newValue
    ValueType valueType
    Overrides
    ValueManager.OnValueChanged(float, ValueType)

    RemoveEventsListeners()

    Remove all listeners from every events, in case we need to destroy the object for example.

    Declaration
    public override void RemoveEventsListeners()
    Overrides
    ValueManager.RemoveEventsListeners()

    ResetToInitialColors()

    Set the Segments, Indicator, Borders and Background colors to their initial values.

    Declaration
    protected virtual void ResetToInitialColors()

    ResetToInitialValues(bool)

    Reset the current and maximum value to their intial values (When ProgressBar Initialize was called)

    Declaration
    public virtual void ResetToInitialValues(bool withAnimations = true)
    Parameters
    Type Name Description
    bool withAnimations

    SetBackground(Sprite)

    Set the background sprite for all segments.

    Declaration
    public virtual void SetBackground(Sprite sprite)
    Parameters
    Type Name Description
    Sprite sprite

    SetInitialColors()

    Override all initial colors with current colors of all the Progress Bar elements.

    Declaration
    protected virtual void SetInitialColors()

    SetPercentageTo(float)

    Set the percentage to instantly update image fill amount.
    So it doesn't show any increase/decrease amount using the shrinking animation.

    Declaration
    public virtual void SetPercentageTo(float percentage)
    Parameters
    Type Name Description
    float percentage

    SetTextFormat(TextFormat)

    Set if we display the current value only, the current value and the maximum value or simply the percentage.

    Declaration
    public virtual void SetTextFormat(TextFormat textFormat)
    Parameters
    Type Name Description
    TextFormat textFormat

    The new text format

    SetValues(object, ValueChangedEventArgs)

    Change the maximum or the current value when ValueChangedEvent is raised from the ValueManager.

    Declaration
    public virtual void SetValues(object sender, ValueChangedEventArgs valueChangedEventArgs)
    Parameters
    Type Name Description
    object sender
    ValueChangedEventArgs valueChangedEventArgs

    SetValues(float, float, bool)

    Modify the current and the maximum value after the initialization.

    Declaration
    public virtual bool SetValues(float current, float maximum, bool overrideInitialValues = false)
    Parameters
    Type Name Description
    float current
    float maximum
    bool overrideInitialValues

    If the initial values are set again

    Returns
    Type Description
    bool

    Shake()

    Shake the ProgressBar Transform

    Declaration
    public void Shake()

    Show()

    Show the health bar using the CanvasGroup.

    Declaration
    public void Show()

    StartPulseAnimation()

    Start the Fill Image pulsing effect.

    Declaration
    public void StartPulseAnimation()

    StopPulseAnimation()

    Stop the Fill Image pulsing effect.

    Declaration
    public void StopPulseAnimation()

    Events

    ActiveConditionChangedEvent

    Raised when a new ProgessBarCondition has been met, so we apply new visuals changes or animations.

    Declaration
    public event EventHandler<ActiveConditionChangedEventArgs> ActiveConditionChangedEvent
    Event Type
    Type Description
    System.EventHandler<TEventArgs><ActiveConditionChangedEventArgs>

    ProgressBarInitializedEvent

    Raised in Initialize() method when the ProgressBar is ready to be used.

    Declaration
    public event EventHandler<ProgressBarInitializedEventArgs> ProgressBarInitializedEvent
    Event Type
    Type Description
    System.EventHandler<TEventArgs><ProgressBarInitializedEventArgs>

    Implements

    IColorChanger
    In This Article
    Back to top Tetra Creations documentation