Class SliderIntWithTickMark
A custom SliderInt UI Element with support for discrete step values, tick marks, and a visual progress bar.
public class SliderIntWithTickMark : SliderInt
Inheritance
object→CallbackEventHandler→Focusable→VisualElement→BindableElement→BaseField<int>→BaseSlider<int>→SliderInt→SliderIntWithTickMarkConstructors
SliderIntWithTickMark()
Default constructor for creating a slider with tick marks and a progress bar.
public SliderIntWithTickMark()
Properties
Step
The value that each step on the slider represents. Used to map between visual value and actual value.
public int Step { get; set; }
Property Value
int
TrueHighValue
Gets or sets the actual maximum value of the slider, based on the custom step size.
public int TrueHighValue { get; set; }
Property Value
int
Remarks
Internally, highValue represents a step index. This property converts that index into
a true maximum by multiplying it with the Step.
For example, if Step = 10 and highValue = 5, the true maximum is 50.
TrueLowValue
Gets or sets the actual minimum value of the slider, based on the custom step size.
public int TrueLowValue { get; set; }
Property Value
int
Remarks
Internally, lowValue represents a step index. This property converts that index into
a true minimum by multiplying it with the Step.
For example, if Step = 10 and lowValue = 2, the true minimum is 20.
TrueValue
Gets or sets the actual value represented by the slider, based on the custom step size.
public int TrueValue { get; set; }
Property Value
int
Remarks
Unity's SliderInt only supports a step size of 1. To simulate custom steps, this property scales the internal slider value by the Step value.
description
- An internal slider value of 2 maps to a true value of 10.
- Setting
TrueValue = 25will storevalue = 5internally (25 / 5).
This allows the slider to behave as if it steps by 5, 10, or any arbitrary increment.
Methods
GenerateTickMarksElements(TickMarkStruct[], VisualTreeAsset)
Instantiates tick mark visual elements using a given data source and prefab.
public VisualElement GenerateTickMarksElements(SliderIntWithTickMark.TickMarkStruct[] ticks, VisualTreeAsset tickMarkPresetAsset)
Parameters
| Name | Type | Description |
|---|---|---|
ticks | SliderIntWithTickMark.TickMarkStruct[] | An arry of tick mark positions and labels. |
tickMarkPresetAsset | VisualTreeAsset | The visual tree asset to use as a prefab for each tick mark. |
Returns
VisualElement — A reference to the visual element container containing all tick mark elements.