Spinner

Has versions for the int and float types.

Note

In case of TextMeshPro error IndexOutOfRangeException: Index was outside the bounds of the array you need to reduce the font size or increase RectTransform size.

Options

  • Interactable bool

    User can interact with this widget.

  • Value Min int/float

    Minimal value.

  • Value Max int/float

    Maximal value.

  • Step int/float

    Step of the value.

  • SpinnerValue int/float

    Current value.

  • Validation SpinnerValidation

    Validate value on specified event.

    • OnKeyDown

      Value checked on every key down event.
      Some value ranges cannot processed correctly with OnKeyDown validation.
      For example 2..10 because to enter 10 you need to enter 1 and 1 is not valid value.
    • OnEndInput

      Value checked when editing has ended.

  • ScrollMode Spinner.ScrollModes

    Change the value on the mouse scroll.

    • Ignore

      Do not change the value on the mouse scroll.

    • UpIncrease

      Increase the value on the mouse wheel up and decrease on the wheel down.

    • UpDecrease

      Decrease the value on the mouse wheel up and increase on the wheel down.

  • AllowHold bool

    Change value on button hold.

  • HoldStartDelay float

    Delay of hold in seconds to start change value.

  • HoldChangeDelay float

    Delay of hold in seconds between each change value.

  • Plus Button ButtonAdvanced

    Button to increase value.

  • Minus Button ButtonAdvanced

    Button to decrease value.

Events

  • onPlusClick UnityEvent

  • onMinusClick UnityEvent

Spinner Events

  • onValueChangeInt UnityEvent<int>

  • onEndEditInt UnityEvent<int>

SpinnerFloat Options

  • Format string

    Value format.

  • Decimal Separators char[]

    Decimal separators.

  • Number Style NumberStyles

    Style of the number.

SpinnerFloat Events

  • onValueChangeFloat UnityEvent<float>

  • onEndEditFloat UnityEvent<float>

Set maximum

spinner.Max = 100;

Set minimun

spinner.Min = 0;

Set value

spinner.Value = 10;

Set step

spinner.Step = 1;

Get value

Debug.Log(spinner.Value);