Documentation

Unity Spark

Open Unity Spark

Unity Spark

Scroll views and scrollbars

Show more content than fits on the screen with the Scroll View and Scrollbar elements in your Unity Spark UI, such as an inventory or a level list.
Read time 2 minutesLast updated 3 hours ago

Use a scroll view when you have more content than fits in a space, such as an inventory, a level list, or credits. The player scrolls to view the rest.

Scroll view

A scroll view is an area that shows part of its content at a time. A new scroll view contains the following parts:
  • Viewport
    : The visible area. Anything outside this area is hidden.
  • Content
    : The object that holds your list items. Place the items inside
    Content
    .
  • Scrollbar Vertical
    and
    Scrollbar Horizontal
    : Bars the player can drag to scroll.
To lay the items out in a column or a grid automatically, add a VerticalLayoutGroup or GridLayoutGroup component to
Content
. To make
Content
grow as you add items, also add a ContentSizeFitter component. For more information, refer to Group and fit elements.
The ScrollRect component of the scroll view sets which directions it scrolls in, and how it moves, for example, whether it bounces at the ends.

Scrollbar

A scrollbar is a bar with a handle that the player drags. Scroll views come with their own scrollbars, but you can also add a scrollbar on its own.

Scrollbar properties

The Scrollbar component contains the following main settings.

Setting

Description

DirectionSets which way the handle moves.
ValueSets the handle position, from
0
to
1
.
SizeSets how much of the bar the handle covers, from
0
to
1
.
Number Of StepsMakes the handle move in steps instead of smoothly.
0
means smoothly.
Buttons, sliders, toggles, input fields, and scrollbars share the following settings.

Setting

Description

InteractableSets whether the player can use the control. When Interactable is disabled, the control shows its Disabled Color.
ColorsSets the tint for each state: Normal Color, Highlighted Color (when the pointer is over it), Pressed Color, Selected Color, and Disabled Color. Color Multiplier brightens every state, and Fade Duration sets how long a change takes.
To respond when the player drags the scrollbar, pass a function to
OnValueChanged
in a script.

Additional resources