Logo
UI Elements

Slider

An extended slider with value formatting

Overview

Slider extends the built in Unity Slider and adds advanced value formatting, optional input field binding, animated handle scaling, and highlighted visuals.

Click here to see the native Unity UI Slider documentation.

Preview


Properties

Formatting

NameTypeDescription
displayMultiplierfloatMultiplies value before formatting
displayFormatDisplayFormatFixed or thousands number formatting
textFormatstringOutput formatting with 0 placeholder

Animation

NameTypeDescription
animationCurveAnimationCurveCurve used when scaling the handle
transitionDurationfloatDuration for scale and highlight transitions
highlightedScalefloatScale factor when hovered
pressedScalefloatScale factor when pressed

Settings

NameTypeDescription
valuefloatSets the slider value
minValuefloatSets the minimum value that can be set
maxValuefloatSets the maximum value that can be set
wholeNumbersboolUse whole numbers such as 0 and 1 without decimals
invokeAtStartboolInvokes onValueChanged at Start

References

NameTypeDescription
valueTextTMP_TextDisplays formatted slider value
valueInputTMP_InputFieldAllows manual input for value
highlightedCGCanvasGroupCanvasGroup used for highlight fade

Events

NameTypeDescription
onValueChangedUnityEventFired when value changed

Code Example

SliderExample.cs
using UnityEngine;
using Evo.UI;

public class SliderExample : MonoBehaviour
{
    public Slider slider;

    void Start()
    {
        // Setup formatting
        slider.displayMultiplier = 1f;
        slider.displayFormat = Slider.DisplayFormat.Fixed1;
        slider.textFormat = "{0}%";

        // Handle value change
        slider.onValueChanged.AddListener(val =>
        {
            Debug.Log("Slider value: " + val);
        });

        // Manually update
        slider.value = 50f;
    }
}

On this page