UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Ui Module / Auto Scroll System Completed

Ui Module — UGTK

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


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:

  1. Add a ScrollRect (the Vertical Scroll View Autoresize prefab of Layout Auto Resize already is one).
  2. Add the Auto Scroll component (UGTK/UI/Auto Scroll) to the ScrollRect GameObject or a parent. If scrollRect is left empty it is resolved from this GameObject or its children in Awake.
  3. Optionally assign Layout Source with the Mn_VerticalAutoResize / Mn_HorizontalAutoResize / Mn_GridAutoResize that 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

Prefabs:


© 2026 Marcello De Bonis. All rights reserved

Real dependenciesOpen in the map →

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.