Class Indicator
Uses an Image component with a Sprite and follows the current value of the progress bar.
We can use a 2D mask to prevent the RectTransform, and therefore the image, from extending beyond the progress bar.
We can also choose any color for the image, but I recommend setting UseSegmentColor to true and then modifying the ColorBrightnessMultiplier.
This way, the image can be slightly brighter (positive multiplier) or darker (negative multiplier) than the colour of the currently active segment.
Inheritance
object
Indicator
Assembly: cs.temp.dll.dll
Syntax
[Serializable]
public class Indicator
Fields
ColorBrightnessMultiplier
Declaration
public float ColorBrightnessMultiplier
Field Value
Enable
Declaration
Field Value
OriginHorizontal
Declaration
public OriginHorizontal OriginHorizontal
Field Value
Type |
Description |
OriginHorizontal |
|
OriginVertical
Declaration
public OriginVertical OriginVertical
Field Value
Type |
Description |
OriginVertical |
|
Use2DMask
Declaration
Field Value
UseSegmentColor
Declaration
public bool UseSegmentColor
Field Value
Properties
Color
Get / Set the indicator color.
Declaration
public Color Color { get; set; }
Property Value
Initialized
Determines if the indicator is ready to be used.
Declaration
public bool Initialized { get; protected set; }
Property Value
Size
Get / Set the indicator rect transform size.
Declaration
public float Size { get; set; }
Property Value
Methods
Hide()
Declaration
Initialize(ProgressBar)
Initial setup, we get the rectTransform of the ProgressBar and the FillSegment to calculate the indicator position when the fill amount change.
Declaration
public void Initialize(ProgressBar progressBar)
Parameters
Initialize2DMask()
Get the RectMask2D component and Enabled it.
Declaration
protected virtual void Initialize2DMask()
OnActiveSegmentChanged(object, SegmentEventArgs)
When the active segment change we may use it's color to change the indicator's color to a brighter or darker tone.
Declaration
protected virtual void OnActiveSegmentChanged(object sender, SegmentEventArgs e)
Parameters
OnProgressBarValueChanged(object, ValueChangedEventArgs)
Change the indicator position and visibility when progress bar values changed
Declaration
protected virtual void OnProgressBarValueChanged(object sender, ValueChangedEventArgs args)
Parameters
SetFillMethodAndOrigin(ProgressBar)
Set the fill method and origin of the indicator based on the ProgressBar values.
Declaration
protected virtual bool SetFillMethodAndOrigin(ProgressBar progressBar)
Parameters
Returns
SetPosition(float)
Move the indicator horizontally on the right end of the filled area segment
Declaration
protected virtual void SetPosition(float percentage)
Parameters
Type |
Name |
Description |
float |
percentage |
|
SetSegmentColor(Color)
Set the indicator color to a brighter or darker using the segment color so we can see the indicator.
Declaration
protected virtual void SetSegmentColor(Color color)
Parameters
Type |
Name |
Description |
Color |
color |
Segment color
|
SetSize()
Set the size of the Indicator's RectTransform according to the chosen fill method.
Declaration
protected virtual void SetSize()
Show()
Declaration
ToggleIndicatorVisibility(float)
Show the indicator if the progress bar amount is above 0.01f, otherwise hide it
Declaration
protected void ToggleIndicatorVisibility(float progressBarPercentage)
Parameters
Type |
Name |
Description |
float |
progressBarPercentage |
|