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
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
_currentValue
Declaration
protected string _currentValue
Field Value
_currentValues
Declaration
protected string _currentValues
Field Value
_font
Declaration
protected TMP_FontAsset _font
Field Value
Type |
Description |
TMP_FontAsset |
|
_fontColor
Declaration
protected Color _fontColor
Field Value
_fontSize
Declaration
protected float _fontSize
Field Value
_maximumValue
Declaration
protected string _maximumValue
Field Value
_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
_textMaximumValue
Declaration
protected TextMeshProUGUI _textMaximumValue
Field Value
Type |
Description |
TextMeshProUGUI |
|
_visible
Declaration
Field Value
FloatFormat
Declaration
public string FloatFormat
Field Value
Properties
Font
Get/Set the Text mesh pro font asset.
Declaration
public TMP_FontAsset Font { get; set; }
Property Value
Type |
Description |
TMP_FontAsset |
|
FontColor
Declaration
public Color FontColor { get; set; }
Property Value
FontSize
Get/Set the font size of the regeneration values.
Declaration
public float FontSize { get; set; }
Property Value
TextFormat
Get / Set the TextFormat to display either : 80 / 100 or 80 or 80 %
Declaration
public TextFormat TextFormat { get; set; }
Property Value
Visible
Declaration
public bool Visible { get; set; }
Property Value
Methods
FormatValue(float)
Declaration
protected virtual string FormatValue(float value)
Parameters
Type |
Name |
Description |
float |
value |
|
Returns
GetValues()
Returns the actual text values in the format : {CurrentValue} {Separator} {MaximumValue}
Declaration
public virtual string GetValues()
Returns
Hide()
Disable the TextMeshProUGUI component
Declaration
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
IsValid()
Checks if the TextMeshProUGUI component is missing.
Declaration
public virtual bool IsValid()
Returns
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
RemoveListeners(ProgressBar)
Stop listening to the ProgessBar.OnValuesChanged event.
Declaration
public virtual void RemoveListeners(ProgressBar progressBar)
Parameters
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
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 |
|