Game.UI.InGame.IntRangeProperty
Assembly: Game
Namespace: Game.UI.InGame
Type: struct
Base: IJsonWritable
Summary:
Represents an integer range property used by the in-game UI. This struct holds the metadata for a numeric range control (labels, min/max values, unit text, and optional icons) and implements IJsonWritable so it can be serialized into the game's JSON format expected by the UI system. The serialized type name used is "Game.UI.Common.NumberRangeProperty".
Fields
-
public string labelId
Identifier for the label text (usually a localization key) displayed next to the range control. -
public int minValue
Minimum integer value allowed by the range control. -
public int maxValue
Maximum integer value allowed by the range control. -
public string unit
Unit string (e.g., "km", "%") shown alongside the numeric value; typically a localization key or literal. -
public bool signed
Whether the range supports signed (negative) values. When true, negative values are valid. -
public string icon
Icon identifier shown with the control (optional). Typically a resource or atlas key. -
public string valueIcon
Icon identifier shown next to the value itself (optional).
Properties
- None. This struct only exposes public fields and does not define properties.
Constructors
public IntRangeProperty()
The default value-type constructor is used. All fields will have their default values (null for strings, 0 for ints, false for bool) unless explicitly assigned.
Methods
public void Write(IJsonWriter writer)
Serializes this IntRangeProperty into the provided IJsonWriter. The output is wrapped in a type block with the type name "Game.UI.Common.NumberRangeProperty" and writes each field as a named JSON property in the following order: labelId, minValue, maxValue, unit, signed, icon, valueIcon.
Parameter: - writer: The IJsonWriter instance used to emit JSON tokens. The writer is expected to support TypeBegin/TypeEnd and PropertyName/Write calls as used by the method.
Notes: - Fields that are null will still be written via writer.Write(null) (behavior depends on writer implementation). - The method does not perform validation (e.g., minValue <= maxValue) — validation should be done by the caller if needed.
Usage Example
// Create and populate an IntRangeProperty
var range = new Game.UI.InGame.IntRangeProperty
{
labelId = "UI_SPEED_LIMIT",
minValue = 0,
maxValue = 120,
unit = "km/h",
signed = false,
icon = "speed_icon",
valueIcon = "speed_value_icon"
};
// Serialize to JSON using a writer implementing IJsonWriter
IJsonWriter writer = /* obtain writer from the UI/serialization system */;
range.Write(writer);
// The writer will produce something equivalent to:
// {
// "$type": "Game.UI.Common.NumberRangeProperty",
// "labelId": "UI_SPEED_LIMIT",
// "minValue": 0,
// "maxValue": 120,
// "unit": "km/h",
// "signed": false,
// "icon": "speed_icon",
// "valueIcon": "speed_value_icon"
// }