Class UnityScrollbarBuilder
Builds a minimal, theme-independent scrollbar (translucent track + draggable handle) entirely in code, so any scrollable view can show scroll feedback without requiring an authored prefab. The bar is anchored as an overlay along the right edge (vertical) or bottom edge (horizontal) of its parent; callers may re-anchor the returned bar to span a specific region (e.g. a menu's visible options area).
Inherited Members
Namespace: Serenity.Ui.Infrastructure.Views
Assembly: Serenity.UnityUi.Infrastructure.dll
Syntax
public class UnityScrollbarBuilder
Constructors
UnityScrollbarBuilder()
Declaration
public UnityScrollbarBuilder()
Fields
DefaultThickness
Declaration
public const float DefaultThickness = 10
Field Value
| Type | Description |
|---|---|
| float | Default thickness of a generated scrollbar in canvas units. |
Methods
Attach(ScrollRect, Scrollbar, bool)
Wires a built scrollbar to a ScrollRect on the matching axis. Uses auto-hide visibility so the bar only appears when the content actually overflows the viewport.
Declaration
public static void Attach(ScrollRect scrollRect, Scrollbar scrollbar, bool vertical)
Parameters
| Type | Name | Description |
|---|---|---|
| ScrollRect | scrollRect | The ScrollRect driving the scrollable content. |
| Scrollbar | scrollbar | A scrollbar created by Build(RectTransform, bool, float). |
| bool | vertical | True to wire the vertical axis; false for the horizontal axis. |
Remarks
AutoHideAndExpandViewport is deliberately avoided: it requires the bar to be a
ScrollRect child with stretch anchors, which the overlay layout does not guarantee.
Build(RectTransform, bool, float)
Creates a scrollbar GameObject under parent anchored as an overlay along
the right edge (vertical) or bottom edge (horizontal).
Declaration
public Scrollbar Build(RectTransform parent, bool vertical, float thickness = 10)
Parameters
| Type | Name | Description |
|---|---|---|
| RectTransform | parent | The RectTransform the scrollbar is created under. |
| bool | vertical | True for a vertical bar (right edge); false for a horizontal bar (bottom edge). |
| float | thickness | Bar thickness in canvas units. |
Returns
| Type | Description |
|---|---|
| Scrollbar | The configured UnityEngine.UI.Scrollbar component, ready to be wired with Attach(ScrollRect, Scrollbar, bool). |