Skip to main content

DiscreteStatBarVisual

A class in Root.Township, Alta.StatSystem.

Client: one segment of a DiscreteStatBar. Has its own material copy so its alpha can change, and can pulse with a scale animation.

Constructors​

MemberWhat it is
DiscreteStatBarVisual()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

7 private and internal fields
MemberWhat it is
private readonly int _AlphaShader property id for _Alpha. Not used; SetAlpha changes the material colour instead.
private AnimateScaleOverTime animatorScale animation used for pings.
private Color colorThe base material's colour, kept so SetAlpha only changes alpha.
private Material materialBase material copied in Awake.
private AltaCoroutine pingCoroutineThe running ping animation, if any.
private Renderer[] renderersRenderers that share the segment's material copy.
private Material usedMaterialThis segment's own copy of material.

Methods​

MemberWhat it is
void Ping(float duration)Plays the scale animation for a number of seconds, restarting it if it's already running. Does nothing while the segment is hidden.
void SetRenderersEnabled(bool isEnabled)Turns the segment's renderers on or off without hiding the object.
4 private and internal methods
MemberWhat it is
private void Awake()Makes a tracked copy of the material and gives it to all the segment's renderers.
private IEnumerator PingAnimation(float duration) (iterator)Coroutine behind Ping: starts the animator, waits, then stops it.
internal void SetActive(bool activeState)Shows or hides the segment, resetting its animation when shown.
internal void SetAlpha(float alpha)Sets the material colour's alpha, keeping the original colour.

Used in​

Members of other types that take, return or hold a DiscreteStatBarVisual: