All Projects → MdIqubal → Recyclable Scroll Rect

MdIqubal / Recyclable Scroll Rect

Licence: mit
Recyclable Scroll Rect reuses or recycles the least number of cells required to fill the viewport. As a result a huge number of items can be shown in the list without any performance hit.

Projects that are alternatives of or similar to Recyclable Scroll Rect

Unmaskforugui
Reverse mask for uGUI element in Unity.
Stars: ✭ 259 (-1.15%)
Mutual labels:  unity, unity3d
Alloy
Alloy physical shader framework for Unity.
Stars: ✭ 244 (-6.87%)
Mutual labels:  unity, unity3d
Midianimationtrack
SMF (.mid) file importer for Unity Timeline
Stars: ✭ 243 (-7.25%)
Mutual labels:  unity, unity3d
Ezsoftbone
A simple kinetic simulator for Unity, you can use it to simulate hair/tail/breast/skirt and other soft objects
Stars: ✭ 241 (-8.02%)
Mutual labels:  unity, unity3d
Deform Prototype
A prototyped framework for deforming meshes in the editor and at runtime in Unity. Not in development anymore, but it's still pretty awesome!
Stars: ✭ 256 (-2.29%)
Mutual labels:  unity, unity3d
Unitysizeexplorer
Visualize how much space each asset in your Unity game takes and quickly optimize your game's file size
Stars: ✭ 242 (-7.63%)
Mutual labels:  unity, unity3d
Colyseus Unity3d
⚔ Colyseus Multiplayer SDK for Unity
Stars: ✭ 251 (-4.2%)
Mutual labels:  unity, unity3d
Nodulus
Puzzle game with clever twists (Unity3d)
Stars: ✭ 232 (-11.45%)
Mutual labels:  unity, unity3d
Unitynuget
Provides a service to install NuGet packages into a Unity project via the Unity Package Manager
Stars: ✭ 257 (-1.91%)
Mutual labels:  unity, unity3d
Gameframework
This is literally a game framework, based on Unity game engine. It encapsulates commonly used game modules during development, and, to a large degree, standardises the process, enhances the development speed and ensures the product quality.
Stars: ✭ 3,318 (+1166.41%)
Mutual labels:  unity, unity3d
Il2cppdumper
Unity il2cpp reverse engineer
Stars: ✭ 3,362 (+1183.21%)
Mutual labels:  unity, unity3d
Tork
Arcade vehicle physics for Unity
Stars: ✭ 256 (-2.29%)
Mutual labels:  unity, unity3d
Roboleague
A car soccer environment inspired by Rocket League for deep reinforcement learning experiments in an adversarial self-play setting.
Stars: ✭ 236 (-9.92%)
Mutual labels:  unity, unity3d
Videoplayereffects
Experimental special effects for VideoPlayer (Unity 5.6 new feature)
Stars: ✭ 252 (-3.82%)
Mutual labels:  unity, unity3d
Hololenscamerastream
This Unity plugin makes the HoloLens video camera frames available to a Unity app in real time. This enables Unity devs to easily use the HoloLens camera for computer vision (or anything they want).
Stars: ✭ 233 (-11.07%)
Mutual labels:  unity, unity3d
Cosinegradient
Cosine gradient generator for Unity
Stars: ✭ 244 (-6.87%)
Mutual labels:  unity, unity3d
Catlib
CatLib for unity3d dependency injection framework
Stars: ✭ 228 (-12.98%)
Mutual labels:  unity, unity3d
Apple Signin Unity
Unity plugin to support Sign In With Apple Id
Stars: ✭ 228 (-12.98%)
Mutual labels:  unity, unity3d
Cradle
Play Twine stories in Unity.
Stars: ✭ 242 (-7.63%)
Mutual labels:  unity, unity3d
Riru Il2cppdumper
Using Riru to dump il2cpp data at runtime
Stars: ✭ 259 (-1.15%)
Mutual labels:  unity, unity3d

Recyclable Scroll Rect

https://twitter.com/polyandcode
https://polyandcode.com || https://www.facebook.com/Polyandcode || https://www.instagram.com/polyandcode/

Available here on the Unity Asset Store

Summary

UPDATE : Recyclable Scroll Rect now supports Horizontal and Grid layout.

Using the default Scroll-Rect to create lists with a huge number of items results in a laggy performance. Especially when creating a list with hundreds or thousands of items, it becomes impossible to use the Scroll Rect with the default approach i.e instantiating that many items. Recyclable Scroll Rect reuses or recycles the least number of cells required to fill the viewport. As a result, a huge number of items can be shown in the list without any performance hit. Vertical, Horizontal and Grid layouts are supported.

Recycling Comparison with Default approach
Imgur Image Imgur Image

Quickstart Guide :

Check the Demo scenes for a complete example

The usage and structure are similar to Native iOS TableViewController. There are mainly two parts in setting up a Recyclable Scroll Rect; Prototype cell and DataSource. Following are the steps to set up a Recyclable Scroll Rect in detail:

  1. Recyclable Scroll View
  2. Prototype cell
  3. Cell class
  4. Datasource

1. Recyclable Scroll View: You can create a Recyclable Scroll View by going to Create -> UI -> Recyclable Scroll View.

2. Prototype Cell: A Prototype cell is basically the cell layout for your list. A prototype cell can be in the hierarchy as the content's child or it can be a prefab. Don’t worry about disabling it if it is present in the hierarchy, it will not show up in play mode. The prototype cell must be assigned to the Recyclable Scroll Rect

3. Cell class: Once you create your desired Prototype cell, assign it to the Recyclable Scroll Rect component. Now you will need to create a Cell script and attach it to the Prototype Cell. This script must be a Monobehaviour implementing ICell interface. The purpose of a Cell script is to configure the cell as the list is scrolled or updated. You must keep reference to the UI items that are required to be updated according to your data source. Check DemoCell class for reference

public class DemoCell : MonoBehaviour, ICell
{
    //UI
    public Text nameLabel;
    public Text genderLabel;
    public Text idLabel;

    //Model
    private ContactInfo _contactInfo;
    private int _cellIndex;

    //This is called from the SetCell method in DataSource
    public void ConfigureCell(ContactInfo contactInfo,int cellIndex)
    {
        _cellIndex = cellIndex;
        _contactInfo = contactInfo;

        nameLabel.text = contactInfo.Name;
        genderLabel.text = contactInfo.Gender;
        idLabel.text = contactInfo.id;
    }
}

4. Data source: The next step is to create a Data source class. A Data source is responsible for data-related operations in the Recyclable Scroll Rect. These are the number of items in the list and how a cell should be configured according to the data. To create a Data source, implement the IRecyclableScrollRectDataSource interface and its methods :
• GetItemCount: This method tells Recyclable Scroll Rect the length of the List.
• SetCell : This method is responsible for configuring the cell UI according to your data. A cell is received as a parameter in this method with its index in the list. Using these, the necessary UI configuration can be done for the cell. The received cell is of ICell type. It must be cast to the implemented Cell type before using.

After the creation of a Cell and Data source, the last step is to assign the Data source instance to the Recyclable Scroll Rect. The assignment must be done in Awake or before the Recyclable Scroll Rect's Start method (Check others section below for details on self-initialization).
Check RecyclableScrollerDemo class for reference

public class RecyclableScrollerDemo : MonoBehaviour, IRecyclableScrollRectDataSource
{
    [SerializeField]
    RecyclableScrollRect _recyclableScrollRect;

    [SerializeField]
    private int _dataLength;

    //Dummy data List
    private List<ContactInfo> _contactList = new List<ContactInfo>();

    //Recyclable scroll rect's data source must be assigned in Awake.
    private void Awake()
    {
        InitData();
        _recyclableScrollRect.DataSource = this;
    }

    #region DATA-SOURCE

    /// <summary>
    /// Data source method. return the list length.
    /// </summary>
    public int GetItemCount()
    {
        return _contactList.Count;
    }

    /// <summary>
    /// Called for a cell every time it is recycled
    /// Implement this method to do the necessary cell configuration.
    /// </summary>
    public void SetCell(ICell cell, int index)
    {
        //Casting to the implemented Cell
        var item = cell as DemoCell;
        item.ConfigureCell(_contactList[index],index);
    }
    
    #endregion
}

Others:
Self-Initiaze: The Recyclable Scroll Rect initializes on its own in its Start method. If you wish to initialize it yourself you can turn off the component's self initialize property and call the Initialize method whenever required. Make sure the Data-source is assigned before initializing.

Reloading Data: If a new data-source is asigned after initialization, call the ReloadData() function. Alternatively ReloadData(IRecyclableScrollRectDataSource dataSource) can also be used for assigning the data-source and reloading data.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].