Scrollable container with inertia, elastic bounds, and optional scrollbar handles. Automatically manages a content child that can be a Column, Row, or manual layout.
Inspector Setup
Add AutoLayout to a container GameObject.
Add AutoLayout Scroll View to the same GameObject.
Content child is created automatically. Children added to the scroll view are reparented to the content container.
Optionally assign scrollbar handle RectTransforms.
Field Type Default Description Scroll Sensitivity float 20 Mouse wheel multiplier Scroll Wheel Axis int 1 0 = horizontal, 1 = vertical Enable Inertia bool true Momentum after drag Enable Elastic Bounds bool true Bounce at edges Deceleration Rate float 0.135 Inertia decay (0.01-0.5) Elasticity Duration float 0.3 Bounce duration Snap Enabled bool false Enable snap-to-interval after scroll ends Snap Interval float 0 Snap interval in pixels (0 = viewport size = page snap) Snap Alignment ScrollSnapAlignment Start Start or Center alignment within interval Snap Speed float 400 Snap animation duration in ms Vertical Scrollbar Handle RectTransform - Optional vertical scrollbar thumb Horizontal Scrollbar Handle RectTransform - Optional horizontal scrollbar thumb
Code Usage
AutoUI Builder
// Vertical scroll view (Column content)
. WidthFill (). HeightFill ()
AutoUI. Create (). WidthFill (). Height ( 100 ). Background (Color.red),
AutoUI. Create (). WidthFill (). Height ( 100 ). Background (Color.green),
AutoUI. Create (). WidthFill (). Height ( 100 ). Background (Color.blue)
// Horizontal scroll view
AutoUI. Create (). Width ( 200 ). HeightFill (). Background (Color.red),
AutoUI. Create (). Width ( 200 ). HeightFill (). Background (Color.green)
AutoUI.ScrollView() (static) is also available as a shortcut for AutoUI.Create().ScrollViewVertical().
. WidthFill (). HeightFill ()
sv.ScrollSensitivity = 30f ;
sv.EnableElasticBounds = true ;
sv.DecelerationRate = 0.1f ;
Page Snap
. WidthFill (). HeightFill ()
// SnapInterval = 0 means page snap (viewport size)
AutoUI. Create (). WidthFill (). HeightFill (). Background (Color.red),
AutoUI. Create (). WidthFill (). HeightFill (). Background (Color.green),
AutoUI. Create (). WidthFill (). HeightFill (). Background (Color.blue)
// Custom interval snap (every 100px)
. WidthFill (). HeightFill ()
sv.SnapAlignment = ScrollSnapAlignment.Center;
var scrollView = go. GetComponent < AutoLayoutScrollView >();
scrollView. ScrollTo ( new Vector2 ( 0 , 500 ), animated : true );
scrollView. ScrollTo ( 500f , animated : true ); // Single axis
scrollView. ScrollBy ( new Vector2 ( 0 , 100 ));
scrollView. ScrollToChild (childTransform, animated : true );
scrollView. StopScrolling ();
// Refresh content size after adding/removing children
scrollView. RefreshContentSize ();
Methods
Method Description ScrollTo(Vector2 position, bool animated = true)Scroll to absolute position ScrollTo(float position, bool animated = true)Scroll single axis ScrollBy(Vector2 delta)Scroll by relative delta ScrollBy(float delta)Scroll single axis by delta ScrollToChild(Transform child, bool animated = true)Scroll to make child visible RefreshContentSize()Recalculate content dimensions StopScrolling()Stop inertia/animation ExcludeFromReparenting(Transform child)Prevent child from being reparented to content
Properties
Property Type Description ContentRectTransform Auto-managed content container ContentModeScrollContentMode Column, Row, or Manual ScrollOffsetVector2 Current 2D scroll offset IsScrollingbool Scroll in progress IsDraggingbool User is dragging CanScrollHorizontalbool Content wider than viewport CanScrollVerticalbool Content taller than viewport ScrollSensitivityfloat Mouse wheel multiplier EnableInertiabool Momentum after drag EnableElasticBoundsbool Edge bounce DecelerationRatefloat Inertia decay rate ElasticityDurationfloat Bounce animation duration PhysicsScrollPhysics Physics simulation instance SnapEnabledbool Snap-to-interval enabled SnapIntervalfloat Snap interval (0 = page) SnapAlignmentScrollSnapAlignment Start or Center SnapSpeedfloat Snap duration in ms IsSnappingbool Snap animation in progress ControllerScrollController Headless controller
Content Modes
Mode Description ColumnContent arranged vertically (default for vertical scroll) RowContent arranged horizontally (default for horizontal scroll) ManualCustom content layout
Notes
Children added to the scroll view are automatically reparented to the content container.
Use ExcludeFromReparenting() for children that should stay as direct children (e.g., scrollbar overlays).
The scroll view integrates with IUGUILayoutDependent to refresh content size after layout.
Implements IScrollHandler, IBeginDragHandler, IDragHandler, IEndDragHandler.
Scrollbar handles auto-resize based on content-to-viewport ratio.