InfiniteScrollView
InfiniteScrollView is made for Unity extension, that support use as less as possible gameObject count to achieve large infinite scrolling content. Developed by native UGUI system, no any magical code inside, so you can easily modify and extend by yourself.
It’s support all platform which Unity supported. Tested on Unity 2019 LTS
You can also get compatible version with older Unity from the link below
2018 LTS
2017 LTS
Features
- Easy customize by OOP concept
- Support diffirent cell height or width
- Full sourcecode and example include
How to use
-
Download this project and copy Assets/InfiniteScrollView to your own project
-
There are three class you have to inherit and implement by your own context
InfiniteCellData
InfiniteCell
VerticalInfiniteScrollView, HorizontalInfiniteScrollView or VerticalGridInfiniteScrollView -
Create CSharp script named
DemoVerticalDateand inheritInfiniteCellData
using HowTungTung;
public class DemoVerticalData : InfiniteCellData
{
public DemoVerticalData(float height)
{
cellSize.y = height;
}
}
- Create CSharp script named
DemoVerticalCelland inheritInfiniteCell<DemoVeritcalData>
using UnityEngine;
using UnityEngine.UI;
using HowTungTung;
public class DemoVerticalCell : InfiniteCell<DemoVerticalData>
{
public Text text;
public override void OnUpdate()
{
RectTransform.sizeDelta = new Vector2(RectTransform.sizeDelta.x, CellData.cellSize.y);
text.text = CellData.cellSize.y.ToString();
}
}
- Create CSharp script named
DemoVerticalScrollViewand inheritVerticalInfiniteScrollView<DemoVerticalData>
using HowTungTung;
public class DemoVerticalScrollView : VerticalInfiniteScrollView<DemoVerticalData>
{
}
- Create CSharp script named
Testeronly for test purpose
using HowTungTung;
public class Tester : MonoBehavior
{
private void Start()
{
var infiniteScrollView = FindObjectOfType<DemoVerticalScrollView>();
for (int i = 0; i < 100; i++)
{
var data = new DemoVerticalData(Random.Range(50, 300));
infiniteScrollView.Add(data);
}
}
}
- Right click on Hierarchy and create UI/Scroll View
- Select
Contentat Scroll View/Viewport/Content on Hierarchy - Right click and create UI/Button
- Click
Anchor Preseton the Button object, and select left top preset with press shift and Alt key - Attach
DemoVerticalCellon this Button and drag into Project window to make to Prefab - Delete the Button from Hierarchy
- Select Scroll View and attach
DemoVerticalScrollViewthen drag the prefab we just created onCell Prefabfield of theDemoVerticalScrollViewcomponent - Attach
Testerto any other gameObject in scene and test it!
For more detail of the example please refer to Assets/Examples
Example