Class RangeSliderInt
A UI component that lets users select a range of integer values by dragging handles along a track.
Inheritance
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class RangeSliderInt : Slider<Vector2Int, int, Vector2IntField>, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder, IInputElement<Vector2Int>, IValidatableElement<Vector2Int>, INotifyValueChanging<Vector2Int>, INotifyValueChanged<Vector2Int>, IFormattable<int>
Remarks
The RangeSliderInt is a UI component that allows users to select a range of integer values by dragging two handles along a track. It's particularly useful when you need to let users define minimum and maximum bounds within a specific range.
The component supports both horizontal and vertical orientations, customizable step values, and various display options for the track and value labels. Users can interact with the slider using mouse/touch input or keyboard navigation.
Unlike a regular slider that has a single value, a range slider operates with two values (minValue and maxValue) that define the selected range. These values can be accessed and modified independently.
Examples
Basic range slider with default settings: creates a horizontal range slider with a range of 0-100 and initial selection of 25-75.
<RangeSliderInt low-value="0" high-value="100" min-value="25" max-value="75" />
Advanced range slider with custom configuration: creates a vertical range slider with custom range, step value, and visual feedback options.
<RangeSliderInt
orientation="Vertical"
low-value="-50"
high-value="50"
step="5"
display-value-label="Auto"
show-marks="true"
track="On"
/>
Range slider with C# event handling: demonstrates how to create a range slider and handle value changes in code.
var rangeSlider = new RangeSliderInt();
rangeSlider.RegisterValueChangedCallback(evt => {
Debug.Log($"Range changed: {evt.newValue.x} - {evt.newValue.y}");
});
Constructors
RangeSliderInt()
Default constructor.
Declaration
public RangeSliderInt()
Properties
maxValue
The high part of the range value.
Declaration
public int maxValue { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
minValue
The low part of the range value.
Declaration
public int minValue { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
thumbCount
Get the number of thumbs for this slider.
Declaration
protected override int thumbCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Overrides
Methods
ClampThumb(int, int, int)
Clamp the thumb value.
Declaration
protected override int ClampThumb(int x, int min, int max)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | The value to clamp. |
| int | min | The minimum value. |
| int | max | The maximum value. |
Returns
| Type | Description |
|---|---|
| int | The clamped values. |
Overrides
GetScalarValuesFromValue(Vector2Int, Span<int>)
Get the list of thumb values from the TValue value. This must be sorted.
Declaration
protected override void GetScalarValuesFromValue(Vector2Int v, Span<int> values)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2Int | v | |
| Span<int> | values | The list of thumb values. |
Overrides
GetStepCount(int)
Declaration
protected override int GetStepCount(int stepValue)
Parameters
| Type | Name | Description |
|---|---|---|
| int | stepValue | The step value. |
Returns
| Type | Description |
|---|---|
| int | The number of possible steps. |
Overrides
GetValueFromScalarValues(Span<int>)
Get the TValue value from the list of thumb values.
Declaration
protected override Vector2Int GetValueFromScalarValues(Span<int> values)
Parameters
| Type | Name | Description |
|---|---|---|
| Span<int> | values | The list of thumb values. |
Returns
| Type | Description |
|---|---|
| Vector2Int | The TValue value. |
Overrides
Mad(int, int, int)
Performs an arithmetic multiply/add operation.
Declaration
protected override int Mad(int m, int a, int b)
Parameters
| Type | Name | Description |
|---|---|---|
| int | m | The number of times to multiply the a value. |
| int | a | The value that will be multiplied N times and then added to the base value. |
| int | b | The addition value. |
Returns
| Type | Description |
|---|---|
| int | The incremented value. |
Overrides
ParseStringToValue(string, out Vector2Int)
Method to implement to resolve a string value into a Vector2Int value.
You can use TryParse(string, out float) for floating point value types for example.
Declaration
protected override bool ParseStringToValue(string strValue, out Vector2Int val)
Parameters
| Type | Name | Description |
|---|---|---|
| string | strValue | The string value to convert. |
| Vector2Int | val |
Returns
| Type | Description |
|---|---|
| bool | True if can be parsed, False otherwise. |
Overrides
ParseSubValueToString(int)
Method to implement to resolve a Vector2Int value into a string value.
You can use ToString() for floating point value types for example.
You can also round the value if you want a specific number of decimals.
Declaration
protected override string ParseSubValueToString(int val)
Parameters
| Type | Name | Description |
|---|---|---|
| int | val | The Vector2Int value to convert. |
Returns
| Type | Description |
|---|---|
| string | The converted value. |
Overrides
ParseValueToString(Vector2Int)
Method to implement to resolve a Vector2Int value into a string value.
You can use ToString() for floating point value types for example.
You can also round the value if you want a specific number of decimals.
Declaration
protected override string ParseValueToString(Vector2Int val)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2Int | val | The Vector2Int value to convert. |
Returns
| Type | Description |
|---|---|
| string | The converted value. |
Overrides
SliderLerpUnclamped(int, int, float)
Method to implement which returns a value based on the linear interpolation of a given interpolant between a specific range.
Usually, you can use directly LerpUnclamped(float, float, float) for floating point value types.
Declaration
protected override int SliderLerpUnclamped(int a, int b, float interpolant)
Parameters
| Type | Name | Description |
|---|---|---|
| int | a | The lowest value in the range. |
| int | b | The highest value in the range. |
| float | interpolant | The normalized value to process. |
Returns
| Type | Description |
|---|---|
| int | The interpolated value. |
Overrides
SliderNormalizeValue(int, int, int)
Method to implement which returns the normalized value of a given value in a specific range.
Usually, you can use directly an InverseLerp(float, float, float) for floating point value types.
Declaration
protected override float SliderNormalizeValue(int currentValue, int lowerValue, int higherValue)
Parameters
| Type | Name | Description |
|---|---|---|
| int | currentValue | The value to normalize. |
| int | lowerValue | The lowest value in the range. |
| int | higherValue | The highest value in the range. |
Returns
| Type | Description |
|---|---|
| float | The normalized value. |