API v1 checking… · p50 — · 0 installs/hr
v0.1.0
Project
View on GitHub
son24tuoi

Circular Scroll Unity

New
0 0

Allows users to scroll through content and loop infinitely when reaching the end of the list.

Unity Project

Download the source from GitHub

Download 0

README

Rendered from GitHub

Circular Scroll - Infinite Loop

Allows users to scroll through content and loop infinitely when reaching the end of the list.

The scroll system optimizes performance by reusing UI elements (GameObjects). Instead of instantiating thousands of objects—which consumes RAM and slows down CPU processing—this system maintains only a small number of elements sufficient to display on the screen and updates their data as the user scrolls.

Key Features

  • High Performance: Only creates the minimum number of objects necessary to fill the viewport.
  • Support for large datasets: Can display lists of up to thousands of items without increasing resource consumption.
  • Easy integration: Based on Unity UI’s standard ScrollRect, the source code can be customized to suit individual preferences.

Comparison with Traditional Methods

Criteria Traditional Scroll Reusable Scroll
Number of Objects Equal to the total amount of data → the more data, the more objects. Fixed, typically twice the number visible in the viewport.
RAM usage Increases gradually with data Low and stable

Operating principle

  • Pagination: Uses the pageIndex variable to control the data boundary.
  • Scrolling: When content reaches the edge of the viewport , it is moved to the appropriate position to allow further scrolling (while updating the displayed data).

Quick setup guide

  1. Attach the CircularScrollVertical.cs/CircularScrollHorizontal.cs script to GameObject containing ScrollRect (you can place it elsewhere too 😅).

  2. Drag the ScrollRect and ContentRT variables for CircularScrollVertical.cs/CircularScrollHorizontal.cs onto the Inspector window. Set the maximum number of list items to display in TotalItems (or set it via code). Other variables displayed in the Inspector will update automatically.

  3. Configure the UI items in the list as child objects of the Content game object (make sure there are just enough to fill the viewport)

  4. Configure CircularScrollVertical.cs/CircularScrollHorizontal.cs using the Init() function with a callback function as a parameter to update data. See the sample script ItemLoader.cs and the sample scene Scene_CircularScroll.

  5. Retrieve the list of UI items in Content using the TryGetComponentsInContentChildren() function. See the sample script ItemLoader.cs and the sample scene Scene_CircularScroll.

Changelog 0 releases

No changelog entries yet. Run the admin Changelog & Version Scanner to pull from the repository's CHANGELOG.md.

Comments

No comments yet. Be the first!