Logo
UI Elements

Scrollbar

An extended Scrollbar component

Overview

Scrollbar extends the built in Unity Scrollbar and adds smooth scrolling, optional auto hide behavior, and arrow button support. It keeps full compatibility with Unity UI while offering modern quality of life improvements.


Properties

Animation

NameTypeDescription
smoothDurationfloatDuration for smooth scrolling animation
smoothCurveAnimationCurveEasing curve for scroll animation

Auto Hide

NameTypeDescription
autoHideboolEnables automatic fade in and fade out
hideAlphafloatAlpha to use when hidden
hideDurationfloatDuration of fade animation
hideTimerfloatTime to wait before starting fade out

References

NameTypeDescription
minArrowButtonOptional button to scroll toward min
maxArrowButtonOptional button to scroll toward max

Public Methods

NameParametersDescription
ScrollToMin()NoneSmoothly scrolls to min edge
ScrollToMax()NoneSmoothly scrolls to max edge
ScrollTo(targetValue)floatSmooth scroll to normalized position
ScrollTo(target, clamp, duration)float, bool, floatFull custom ScrollTo
ScrollBy(amount)floatAdditive scroll
ScrollBy(amount, clamp, duration)float, bool, floatAdditive scroll with settings

Code Example

ScrollbarExample.cs
using UnityEngine;
using Evo.UI;

public class ScrollbarExample : MonoBehaviour
{
    public Scrollbar scrollbar;

    void Start()
    {
        // Smooth scroll to 50%
        scrollbar.ScrollTo(0.5f);

        // Scroll by +0.1
        scrollbar.ScrollBy(0.1f);

        // Scroll instantly using Unity directly
        scrollbar.value = 1f;

        // Scroll to min or max
        scrollbar.ScrollToMin();
        scrollbar.ScrollToMax();
    }

    void Update()
    {
        // Example: scroll wheel manually
        if (Input.GetKeyDown(KeyCode.UpArrow))
            scrollbar.ScrollBy(0.1f);

        if (Input.GetKeyDown(KeyCode.DownArrow))
            scrollbar.ScrollBy(-0.1f);
    }
}

On this page