Game.UI.Widgets.IntSliderField
Assembly: Assembly-CSharp
Namespace: Game.UI.Widgets
Type: class
Base: IntField
Summary:
IntSliderField is a UI widget that represents an integer input field combined with slider-style dragging behavior. It supports an optional unit label, signed/unsigned formatting, thousands separators, scaled drag volume, and an optional "update on drag end" mode. The widget can signal a warning state either by setting the boolean property or by providing a warningAction delegate that will be evaluated each update to toggle the warning state automatically.
Fields
private bool m_Warning
Backing field used to store the current warning state. The public warning property reads/writes this value and setter clears any warningAction when assigning directly.
Properties
-
[CanBeNull] public Func<bool> warningAction { get; set; }
Optional delegate evaluated each Update() cycle (if set). When it returns true the widget's warning state will be set; when it returns false the warning state will be cleared. If you assign directly to warning the setter will clear this delegate. -
[CanBeNull] public string unit { get; set; }
Optional unit text to display alongside the numeric value (for example "km/h" or "%"). -
public bool signed { get; set; }
If true, the control will allow and format negative values (showing a sign). If false, values are treated/displayed as unsigned. -
public bool separateThousands { get; set; }
If true, the displayed number will include thousands separators for readability (for example "12,345"). -
public bool scaleDragVolume { get; set; }
When dragging to change the value, enabling this will adjust how fast the value changes (scaled drag sensitivity). Use this to provide fine/coarse control. -
public bool updateOnDragEnd { get; set; }
If true, the control will delay applying some updates until drag ends (useful if you want to avoid continuous expensive updates while the user is dragging). -
public bool warning { get; set; }
Boolean property for the warning state. Getting returns the current state (m_Warning). Setting to a value clears any warningAction delegate (warningAction = null) and updates the stored m_Warning.
Constructors
public IntSliderField()
Default constructor (no explicit constructor is defined in the source; the default parameterless constructor is available). Use it to create a new widget instance and then set properties as needed.
Methods
-
protected override WidgetChanges Update()
Called during the widget update cycle. Calls base.Update() and, if warningAction is non-null, invokes it to determine whether the warning state should change. If the warning state changes, the method marks the widget's properties as changed by OR-ing WidgetChanges.Properties into the returned value so the UI system can react to the change. -
protected override void WriteProperties(IJsonWriter writer)
Serializes widget-specific properties to a JSON writer (used by the UI system when emitting widget definitions). Writes the following properties (in this order): "unit", "signed", "separateThousands", "scaleDragVolume", "updateOnDragEnd", and "warning". Each property is written as its current value.
Usage Example
// Create and configure an IntSliderField
var speedField = new IntSliderField
{
unit = "km/h",
signed = false, // no negative speeds
separateThousands = true, // show "1,000" instead of "1000"
scaleDragVolume = true, // smoother scaled dragging
updateOnDragEnd = false // update while dragging
};
// Example: set warning via delegate (e.g., warn when speed exceeds 120)
speedField.warningAction = () => speedField.value > 120;
// Or set warning directly (this clears warningAction)
speedField.warning = false;
// Add the widget to a parent container as required by the UI framework:
// parent.AddChild(speedField);
// Note: The widget will call warningAction during its Update() cycle and
// will write its properties via WriteProperties when the UI system serializes it.