Skip to main content

StatBar

A class in Root.Township, Alta.StatSystem.

A curved stat bar that adds notch marks for the stat's maximum and an icon to StatBarSimple. Display only.

Constructors​

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

Fields​

11 private and internal fields
MemberWhat it is
private float angleWidthAngle the bar covers, used to place notches (default 90).
private Material iconMaterialSource material for the stat icon.
private bool isUsingNotchesWhether the bar shows notches.
private bool isUsingOverrideMaterialTrue after ForceNotchMaterial.
private List<StatBarNotch> notchesThe spawned notches.
private Transform notchParentTransformParent for spawned notches; the bar itself if empty.
private StatBarNotch notchPrefabPrefab spawned for each notch.
private Material overrideNotchMaterialMaterial set by ForceNotchMaterial.
private Material reachedNotchMaterialSource material for reached notches.
private MeshRenderer statIconRendererRenderer for the stat icon.
private Material unreachedNotchMaterialSource material for unreached notches.

Properties​

MemberWhat it is
Material IconMaterial { get; private set; }Copy of the icon material made in Initialize, used to fade the icon.
Material ReachedMaterial { get; private set; }Material copy for notches the stat has reached.
Material UnreachedMaterial { get; private set; }Material copy for notches the stat has not reached.

Methods​

MemberWhat it is
override void ForceNotchMaterial(Material notchesMaterial)Uses one material for every notch from now on, instead of reached and unreached materials.
override void Initialize()Makes copies of the icon and notch materials so this bar can fade them alone.
override void SetAlpha(float alphaMultiplier)Fades the bar, icon and notch materials.
protected override void OnStatChanged(Stat stat)Updates the bar and then its notches.
protected override void SetRenderersEnabled(bool isEnabled)Shows or hides the bar and all notches.
5 private and internal methods
MemberWhat it is
private void DebugNotchVisibility(StatDefinition definition, out float statMaximum)Sets the editor preview maximum to 0. Leftover debug hook.
private void DelayDestroy()Destroys all notch objects.
private void DelaySetup()Calls SetupNotches with no stat. Leftover editor helper.
private void OnValidate()Does nothing.
private void SetupNotches(Stat stat)Colours notches by whether the stat reaches them (not on Android), and rebuilds and places them when the maximum changes.

Used in​

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