-
Notifications
You must be signed in to change notification settings - Fork 0
Sliders.md
Sliders are modified to have a better look than unity standard.
It adds
- Options to define the label position
- Options to write the value in the label
- Min - Max limits drawn on bottom
- a green line (just for the look)

use the K2Slider or K2SliderInt, they share the same style and attributes. but the behavior is slightly different

- Label : if none the Label is hidden
- Label On Top : if true label is located on top of slider, if false on the left
-
Print Value : print values in the label
-
Min Max Label : adds a line on the bottom to show min and max values.
- use the
xvalue, the real Min Max value will be printed there :
- use a formated string like
cold-hot(separated with a -)
- use the
- Value : the startvalue
- Min : The minimum value
- Max : the maximum value
like standard Unity Editor fields it can be finely adjusted by draging the label.

It can be bound with a Setting<float> or ClampSetting<float> for K2Slider
and with Setting and ClampSettingInt for the K2SliderInt.
If you bind a ClampSetting, min and max properties are copied from the settings to the UI.
ex :
public ClampSettingInt int_item = new ClampSettingInt("my_settings.int_item", -5, -10, 10);
public ClampSetting<float> float_item = new ClampSetting<float>("my_settings.float_item", 5, 0, 100);
public void init(VisualElement panel)
{
// min max values are taken from the settings
panel.Q<K2SliderInt>("int_settings").Bind(int_item);
panel.Q<K2Slider>("float_settings").Bind(settings.float_item);
}- the buttons uses the
.k2-sliderclass. The whole list of subclasses are located into K2Slider.uss
Thoses classes mainly overload defaults uss values from the standard Slider.
This control is deeply inspired from the tutorial Nj Tutorial
thanks for this excellent tutorial. I've learn much there.
The controler is mainly a modified version of the Standard Unity Slider. The Label is moved depending on the label_on_top value. It has been tricky to make without anoying the rest of default Slider Behavior. There were many case of flickering from left to top. so take care if you want to do modifications of the codes.
The green line is added using a Visualelement that is aligned with the Dragger Element. It is located inside the round center line to avoid flickering.
The Min - Max Is a new labels added on bottom.