SliderComponent
extends BaseComponent implements IStylable<SliderComponent, SliderStyle>
Description
The SliderComponent is quite simple as it, simimlar to the InputComponent, simply tries to mirror what the native uGUI functionaly offers with some additional configuration options.
You can customize the background, foreground and handle, as well as
configure MaxValue and MinValue for your range.
For a basic slider simlpy use the provided builder with your custom SliderStyle!
important
If the range of the slider is incorrectly ordererd (min value is larger than max) the range will automatically be flipped.
Examples
Simple UI Builder
SliderComponent slider = UI.Slider(new Range(0, 1), builder =>
{
// optionally style your slider here ...
builder.Foreground(_fillSprite);
builder.Background(_backgroundSprite);
builder.Handle(_handleSprite);
// ... and modify its behaviour
builder.IntegerSteps();
}, newVal =>
{
// optional on value changed callback
})
.Parent(canvas);
Debug.Log(slider.Value) // retrieve the current value in the slider