RangeSlider

Slider with two handles for minimum and maximum. Has versions for the int and float types.

Options

  • Type RangeSliderType

    Type of the slider.

    • AllowHandleOverlay

      Handles can intersects. Value scale is constant.

    • DisableHandleOverlay

      Handles can not intersects. Value scale is variable.

  • Value Min int/float

    Minimal value.

  • Value Max int/float

    Maximal value.

  • Step int/float

    Step of the value.

  • Limit Min int/float

    Value cannot be less that this.

  • Limit Max int/float

    Value cannot be more that this.

  • Handle Min RangeSliderHandle

    Handle to change the minimal value.

  • Handle Max RangeSliderHandle

    Handle to change the maximal value.

  • UsableRangeRect RectTransform

    Usable range.

  • FillRect RectTransform

    GameObject to display fill (line from minimal value to the maximal value).

  • Whole Number Of Steps bool

    Whole number of steps for the value.

Events

  • OnValuesChange UnityEvent<int, int>/UnityEvent<float, float>

  • OnChange UnityEvent

Set values

slider.ValueMin = 10;
slider.ValueMax = 80;

Set step

slider.Step = 2;

Set limits

slider.LimitMin = 0;
slider.LimitMax = 100;

Add listener

void Start()
{
   slider.OnValuesChange.AddListener(SliderChanged);
}

void SliderChanged(int min, int max)
{
   if (slider.WholeNumberOfSteps)
   {
      Debug.Log(string.Format("Range: {0:000} - {1:000}; Step: {2}", min, max, slider.Step));
   }
   else
   {
      Debug.Log(string.Format("Range: {0:000} - {1:000}", min, max));
   }
}