UGTK / Toolkit / Ui Module / Auto Scroll System Completed
Auto Scroll System
Summary
The Auto Scroll System drives a ScrollRect automatically at a constant pixel speed, pausing at
each edge — the behaviour used by the Socialbooth leaderboards (Quizfy / TakeTheMole). It works on
either axis, supports ping-pong / loop / once modes, and reacts to a UGTK
Layout Auto Resize
list whose items change at runtime.
Content
Modules Dependencies
- Layout Auto Resize: optional but supported — the scroller listens to the list's
onItemAdded/onItemRemoved/onClearedevents. Items can be added while it scrolls (a leaderboard filling up) and the motion simply continues at the same speed towards the new end.
Setup
Drop the Auto Scroll View prefab under a Canvas — a ready-made vertical ScrollRect with the
component already configured (60 px/s, PingPong, Layout Source already wired to the content's
Mn_VerticalAutoResize):
The prefab ships with 13 placeholder rows baked in so the scroll is visible immediately: delete them (or clear the content) before using it in production.
Or set it up by hand:
- Add a
ScrollRect(theVertical Scroll View Autoresizeprefab of Layout Auto Resize already is one). - Add the Auto Scroll component (
UGTK/UI/Auto Scroll) to the ScrollRect GameObject or a parent. IfscrollRectis left empty it is resolved from this GameObject or its children inAwake. - Optionally assign Layout Source with the
Mn_VerticalAutoResize/Mn_HorizontalAutoResize/Mn_GridAutoResizethat fills the content.
How To Use
Configure it in the inspector and it runs on enable (autoStart). Typical leaderboard setup:
scroll to the bottom, pause 30s while the new scores download, scroll back up, pause, repeat.
autoScroll.StartScroll(); // start (or restart) from the start edge
autoScroll.StopScroll(); // stop where it is
autoScroll.ResetToStart(); // snap back to the start edge
autoScroll.SetSpeed(90f); // pixels per second, at runtime
bool running = autoScroll.IsScrolling;
Tune it from the inspector — mode, speed and the two edge pauses are the settings you change most:
Key options:
- Auto Start: starts scrolling on enable (on by default).
- Axis: Auto (taken from the ScrollRect), Vertical, Horizontal.
- Mode: PingPong (end ↔ start forever), LoopToStart (snap back and repeat), Once.
- Scroll Speed Pixels Per Second: constant speed, independent from how long the list is.
- Max Scroll Delta Time: caps the per-frame step. Without it, a long frame (a leaderboard
re-download) makes the scroll jump forward by all the missed time at once.
- Pause At End / Start Seconds: how long to hold still at each edge.
- Resume When Items Change: only relevant in Once mode — if the scroll already finished and new
items arrive, resume towards the new end instead of staying stopped.
Growing lists never jump. The scroll is stepped in pixel space, not normalized space: the pixel offset is read back from the ScrollRect every frame, so appending rows leaves the view exactly where it is and it keeps moving at the same speed towards the new, farther end. (In normalized space the same value would mean a different pixel offset once the content grows, and the list would visibly jump.)
Events: On Reached End and On Reached Start fire once, at the start of each pause — wire heavy work
(such as the leaderboard download) to them so any hitch happens while the view is still. They are
serialized private fields: wire them from the inspector, there is no AddListener from code.
If the content is shorter than the viewport the view stays pinned at the start edge, but the phase cycle keeps running so the edge events still fire on schedule.
Testing Scene
Open Debug/AutoScrollScene.unity and press Play: the list scrolls to the bottom, holds, scrolls back
up and repeats (PingPong). The scene ships with the default 30 s pauses — lower Pause At End/Start
Seconds to 1–2 s to see a full cycle quickly:
Technical Info
- Mn_AutoScroll: the component — phase machine (scroll → pause → scroll back → pause), axis-agnostic
pixel-space stepping at a constant speed, and the Layout Auto Resize hook. Resolves the
ScrollRectfrom itself or its children when the field is empty. - E_AutoScrollAxis:
Auto/Vertical/Horizontal. - E_AutoScrollMode:
PingPong/LoopToStart/Once. - Mn_AutoScrollEditor: custom inspector (default properties plus a help box about the Layout Source integration); no extra buttons.
Prefabs:
- Auto Scroll View: vertical ScrollRect (Viewport + Content with
VerticalLayoutGroupandMn_VerticalAutoResize) withMn_AutoScrollpre-configured and 13 placeholder rows.
© 2026 Marcello De Bonis. All rights reserved
Depends on 1
Used by 0
- No other module depends on it.
Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 4 modules in total.
UGTKengine within an engine


