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:
- : The visible area. Anything outside this area is hidden.
Viewport - : The object that holds your list items. Place the items inside
Content.Content - and
Scrollbar Vertical: Bars the player can drag to scroll.Scrollbar Horizontal
To lay the items out in a column or a grid automatically, add a VerticalLayoutGroup or GridLayoutGroup component to . To make grow as you add items, also add a ContentSizeFitter component. For more information, refer to Group and fit elements.
ContentContentThe 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 |
|---|---|
| Direction | Sets which way the handle moves. |
| Value | Sets the handle position, from |
| Size | Sets how much of the bar the handle covers, from |
| Number Of Steps | Makes the handle move in steps instead of smoothly. |
Buttons, sliders, toggles, input fields, and scrollbars share the following settings.
Setting | Description |
|---|---|
| Interactable | Sets whether the player can use the control. When Interactable is disabled, the control shows its Disabled Color. |
| Colors | Sets 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 in a script.
OnValueChanged