Search Results for

    Show / Hide Table of Contents

    Class ProgressBarText

    Converts the floating point values to the desired format to display them on the progress bar.
    By default we show the current and maximum value, but we can choose to show the percentage or the only the current value.

    Inheritance
    object
    ProgressBarText
    Namespace: TetraCreations.ProgressBarSystem
    Assembly: cs.temp.dll.dll
    Syntax
    [Serializable]
    public class ProgressBarText

    Fields

    _canvasGroup

    Declaration
    protected CanvasGroup _canvasGroup
    Field Value
    Type Description
    CanvasGroup

    _currentPercentage

    Declaration
    protected string _currentPercentage
    Field Value
    Type Description
    string

    _currentValue

    Declaration
    protected string _currentValue
    Field Value
    Type Description
    string

    _currentValues

    Declaration
    protected string _currentValues
    Field Value
    Type Description
    string

    _font

    Declaration
    protected TMP_FontAsset _font
    Field Value
    Type Description
    TMP_FontAsset

    _fontColor

    Declaration
    protected Color _fontColor
    Field Value
    Type Description
    Color

    _fontSize

    Declaration
    protected float _fontSize
    Field Value
    Type Description
    float

    _maximumValue

    Declaration
    protected string _maximumValue
    Field Value
    Type Description
    string

    _separator

    Declaration
    protected TextMeshProUGUI _separator
    Field Value
    Type Description
    TextMeshProUGUI

    _textCurrentValue

    Declaration
    protected TextMeshProUGUI _textCurrentValue
    Field Value
    Type Description
    TextMeshProUGUI

    _textFormat

    Declaration
    protected TextFormat _textFormat
    Field Value
    Type Description
    TextFormat

    _textMaximumValue

    Declaration
    protected TextMeshProUGUI _textMaximumValue
    Field Value
    Type Description
    TextMeshProUGUI

    _visible

    Declaration
    protected bool _visible
    Field Value
    Type Description
    bool

    FloatFormat

    Declaration
    public string FloatFormat
    Field Value
    Type Description
    string

    Properties

    Font

    Get/Set the Text mesh pro font asset.

    Declaration
    public TMP_FontAsset Font { get; set; }
    Property Value
    Type Description
    TMP_FontAsset

    FontColor

    Get/Set the font color.

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

    FontSize

    Get/Set the font size of the regeneration values.

    Declaration
    public float FontSize { get; set; }
    Property Value
    Type Description
    float

    TextFormat

    Get / Set the TextFormat to display either : 80 / 100 or 80 or 80 %

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

    Visible

    Show / Hide the Text.

    Declaration
    public bool Visible { get; set; }
    Property Value
    Type Description
    bool

    Methods

    FormatValue(float)

    Return a float value as string using the FloatFormat.
    More information about numeric formating : https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings

    Declaration
    protected virtual string FormatValue(float value)
    Parameters
    Type Name Description
    float value
    Returns
    Type Description
    string

    GetValues()

    Returns the actual text values in the format : {CurrentValue} {Separator} {MaximumValue}

    Declaration
    public virtual string GetValues()
    Returns
    Type Description
    string

    Hide()

    Disable the TextMeshProUGUI component

    Declaration
    public void Hide()

    Initialize(ProgressBar)

    Initial setup, we get the rectTransform of the progess bar and the FillSegment to calculate the indicator position when the fill amount change.

    Declaration
    public virtual void Initialize(ProgressBar progressBar)
    Parameters
    Type Name Description
    ProgressBar progressBar

    IsValid()

    Checks if the TextMeshProUGUI component is missing.

    Declaration
    public virtual bool IsValid()
    Returns
    Type Description
    bool

    OnValueChanged(object, ValueChangedEventArgs)

    When the Progress Bar values (Current / Maximum) changes we update the text of the TextMeshProUGUI components.
    To save some performance, we avoid updating uncessary string if we use TextFormat.Percentage for example _currentValue and _maximumValue are not updated.

    Declaration
    protected virtual void OnValueChanged(object sender, ValueChangedEventArgs arg)
    Parameters
    Type Name Description
    object sender
    ValueChangedEventArgs arg

    RemoveListeners(ProgressBar)

    Stop listening to the ProgessBar.OnValuesChanged event.

    Declaration
    public virtual void RemoveListeners(ProgressBar progressBar)
    Parameters
    Type Name Description
    ProgressBar progressBar

    SetText()

    Update the text of the TextMeshProUGUI which either the cached percentage or the values.

    Declaration
    protected virtual void SetText()

    Show()

    Enable the TextMeshProUGUI component

    Declaration
    public void Show()

    UpdateValue(float, ValueType)

    Update the new string values in cache

    Declaration
    public virtual void UpdateValue(float value, ValueType valueType)
    Parameters
    Type Name Description
    float value

    The new value

    ValueType valueType

    Which value changed, it's an enum flag.

    UpdateValueAsPercentage(float)

    Update the new percentage value in cache.

    Declaration
    public virtual void UpdateValueAsPercentage(float percentage)
    Parameters
    Type Name Description
    float percentage
    In This Article
    Back to top Tetra Creations documentation