Vietnamese


https://github.com/son24tuoi/recyclable-scroll-unity.git


The scroll system optimizes performance by reusing UI elements (GameObjects). Instead of creating thousands of objects that consume RAM and slow down CPU processing, this system maintains only a small number of elements sufficient to display on the screen and updates their data as the screen is scrolled.

Key Features

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

Quick Setup Guide

  1. Attach theRecyclableScrollVertical.cs / RecyclableScrollHorizontal.cs script to the GameObject containing the ScrollRect (you can place it elsewhere too 😅).
  2. Drag theScrollRect and ContentRT variables for RecyclableScrollVertical.cs / RecyclableScrollHorizontal.cs onto the Inspector window. Set the maximum number of list items to display in TotalItems (or set it via code). Other variables visible in the Inspector will update automatically.
  3. Configure the UI items in the list as child objects of the Content game object (make sure the number is just enough to fill the viewport).
  4. Configure RecyclableScrollVertical.cs / RecyclableScrollHorizontal.cs using the Init() function with a callback function as a parameter to update the data. See the sample script ItemLoader.cs and the sample scene Scene_RecyclableScroll inSamples.