Skip to content

Game.UI.Widgets.FloatSliderField

Assembly: Assembly-CSharp.dll
Namespace: Game.UI.Widgets

Type: public class

Base: FloatSliderField, IWarning

Summary:
FloatSliderField is a UI widget representing a floating-point slider that stores its value as a double. It specializes the generic FloatSliderField for double, exposing a "warning" state (via the IWarning interface) that can be driven either directly or via a supplied Func (warningAction). The class overrides default min/max to the full range of double and provides conversion from Unity.Mathematics.double4 to the field's double value (takes the .x component).


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 base; behaviors like value storage, formatting, and UI rendering are implemented by the base class and are not shown here. - ToFieldType(double4) indicates the widget may interact with vectorized data or job systems that return a double4; only the x component is used. - Setting warning via the property intentionally nulls warningAction to avoid conflicts between direct setting and delegate-based evaluation. - The class implements IWarning; use of that interface in the UI framework may enable warning-specific styling or behavior. }}