Skip to main content

NumericalWidget

A class in Root.Township, the global namespace.

Debug widget that shows a number and builds up and down buttons for each digit, firing events when the value changes.

Constructors​

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

Fields​

10 private and internal fields
MemberWhat it is
private AnalyticalButton buttonPrefabButton prefab used for each digit.
private float currentValueThe current value.
private int decimalPlacesNumber of digits after the point.
private bool isPercentageIf true, events get the value divided by 100.
private float maxHighest value; also sets how many whole digits get buttons.
private float minLowest value.
private Renderer minusSignalRenderer shown when the value is negative.
private FloatUnityEvent onValueChangedEvent fired with the new value.
private IntUnityEvent onValueChangedIntEvent fired with the new value cast to an int.
private TextRenderer textRendererText that shows the value.

Properties​

1 private and internal property
MemberWhat it is
private string Format { get; }Number format with enough digits for max and the set decimal places.

Methods​

4 private and internal methods
MemberWhat it is
private int GetPlacesAboveZero()Number of digits in the whole part of max.
private void Start()Shows the value and creates a pair of up and down buttons for each digit.
private void UpdateText()Shows the absolute value and turns on the minus sign if negative.
private void UpdateValue(float newValue)Clamps and sets a new value, updates the text and fires both events (divided by 100 if a percentage).