RangeSlider
Slider with two handles for minimum and maximum. Has versions for the int and float types.
Options
Type
RangeSliderTypeType of the slider.
AllowHandleOverlayHandles can intersects. Value scale is constant.
DisableHandleOverlayHandles can not intersects. Value scale is variable.
Value Min
int/floatMinimal value.
Value Max
int/floatMaximal value.
Step
int/floatStep of the value.
Limit Min
int/floatValue cannot be less that this.
Limit Max
int/floatValue cannot be more that this.
Handle Min
RangeSliderHandleHandle to change the minimal value.
Handle Max
RangeSliderHandleHandle to change the maximal value.
UsableRangeRect
RectTransformUsable range.
FillRect
RectTransformGameObject to display fill (line from minimal value to the maximal value).
Whole Number Of Steps
boolWhole number of steps for the value.
Events
OnValuesChanged
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));
}
}