Game.UI.Widgets.FloatSliderField
Assembly: Assembly-CSharp.dll
Namespace: Game.UI.Widgets
Type: public class
Base: FloatSliderField
Summary:
FloatSliderField is a UI widget representing a floating-point slider that stores its value as a double. It specializes the generic FloatSliderField
Fields
-
private bool m_Warning
Holds the current warning state of the widget. Used internally and exposed through the public warning property. -
private
(none other declared)
All other state is inherited from the generic base. The class exposes a public property warningAction (see Properties).
Properties
-
public Func<bool> warningAction { get; set; }
[CanBeNull] A delegate that, when set, is invoked each Update() to determine whether the widget should be in a warning state. If the delegate's result differs from the current m_Warning, the widget updates its internal state and flags property changes. -
protected override double defaultMin => double.MinValue
Overrides the base default minimum value to the smallest double. -
protected override double defaultMax => double.MaxValue
Overrides the base default maximum value to the largest double. -
public bool warning { get; set; }
Gets or sets the warning state. Setting this property clears any warningAction (sets warningAction = null) and directly sets the internal m_Warning field.
Constructors
public FloatSliderField()
Implicit default constructor. The class does not declare an explicit constructor; initialization relies on base class construction and property setters.
Methods
-
public override double ToFieldType(double4 value)
Converts a Unity.Mathematics.double4 to the field's double value. Implementation returns value.x (the first component of the vector). -
protected override WidgetChanges Update()
Calls the base Update() and then, if warningAction is not null, invokes it. If the returned boolean differs from the current m_Warning, updates m_Warning and marks WidgetChanges.Properties so the UI knows properties changed. -
protected override void WriteProperties(IJsonWriter writer)
Serializes widget properties to JSON by calling the base implementation and then writing a "warning" boolean property with the current warning value.
Usage Example
// Example: create a double-based slider and drive its warning state via a delegate.
var slider = new FloatSliderField();
slider.warningAction = () =>
{
// Example condition: set warning if slider value exceeds some threshold.
// 'value' getter comes from the base FloatSliderField<T> API (not shown here).
return slider.value > 100.0;
};
// Alternatively, set warning directly and clear any action:
slider.warning = true; // this clears warningAction internally
// When the UI system calls Update(), the slider will evaluate warningAction
// and update its warning state; WriteProperties will include "warning" in JSON output.
{{ Additional notes:
- The class depends on the generic FloatSliderField