Class DigitalGauge
Text-based digital gauge for numbers or strings, with an optional progress bar, numeric smoothing and flexible formatting. Requires a child GameObject named "Readout" (Text), plus an optional "Line" (Image) for the progress bar.
Namespace: NWH.VehiclePhysics2.VehicleGUI
Assembly: NWH.VehiclePhysics2.dll
Syntax
public class DigitalGauge : MonoBehaviour
Fields
format
Format string for numerical values using C# standard numeric format strings. Examples: "0" = no decimals, "0.0" = one decimal, "0.00" = two decimals, "000" = zero-padded to 3 digits.
Declaration
[Tooltip("Numerical value formatting.")]
public string format
Field Value
| Type | Description |
|---|---|
| string |
gaugeType
Numerical reads numericalValue with formatting and smoothing, Textual reads stringValue as-is (gear indicators and the like).
Declaration
[Tooltip("Should the stringValue or numericalValue be used. String value is useful for e.g. gear (R, N, 1, 2, 3) and numerical\r\nfor\r\nspeed, RPM or similar.")]
public DigitalGauge.GaugeType gaugeType
Field Value
| Type | Description |
|---|---|
| DigitalGauge.GaugeType |
maxValue
Maximum value for calculating progress bar percentage. Only relevant when showProgressBar is enabled. For example, set to 8000 for an RPM gauge that goes to 8000 RPM.
Declaration
[Tooltip("Maximum value that the gauge can display. Only used if showProgressBar enabled.")]
public float maxValue
Field Value
| Type | Description |
|---|---|
| float |
numericalSmoothing
Smoothing on numerical transitions, 0 for instant and 1 for the heaviest damping. 0.3-0.7 keeps a speed or RPM readout from jumping.
Declaration
[Range(0, 1)]
[Tooltip("Time over which the numerical value will be smoothed.")]
public float numericalSmoothing
Field Value
| Type | Description |
|---|---|
| float |
numericalValue
Value shown in Numerical mode, run through format and numericalSmoothing.
Declaration
[Tooltip("Numerical value that will be displayed on the gauge.")]
public float numericalValue
Field Value
| Type | Description |
|---|---|
| float |
showProgressBar
Fills a horizontal line with numericalValue over maxValue. Needs a child named "Line" carrying an Image, and Numerical mode; Start forces it off in Textual mode.
Declaration
[Tooltip("Should the progress line/bar be displayed for better visualization?")]
public bool showProgressBar
Field Value
| Type | Description |
|---|---|
| bool |
stringValue
Value shown in Textual mode, with no formatting or smoothing.
Declaration
[Tooltip("String value that will be displayed on the gauge.")]
public string stringValue
Field Value
| Type | Description |
|---|---|
| string |
unit
Unit appended after the value ("km/h", "RPM", "°C"), separated by a space.
Declaration
[Tooltip("Unit displayed after the value, e.g., km/h.")]
public string unit
Field Value
| Type | Description |
|---|---|
| string |