Recyclable List View in Unity: Complete Project
This week, when working on a country selection list, I’ve decided to have some fun trying to implement a recyclable list view in Unity 3d (something inspired in Android’s ListView recycling mechanism).
The main advantage of using a recycling mechanism is that, instead of instantiating a new row for each list item, a minimum number of rows is instantiated and when necessary, each existing row is updated to represent a new list item. In this way, the number of rows becomes independent of the list length.
Recyclable List View Breakdown
How to use it
- Drag the List prefab to a Canvas gameObject; IMAGE1
- Implement your own ListItem component – extend the ListItemBase.cs – and assign it to the List component (use the ListItem prefab and replace the component); IMAGE2
- Create a controller with a reference to the List component and the ListItem prefab – check the example below; IMAGE3
This week goal was to implement a Photo Gallery controller with Fullscreen and Page Control Dots on top of my List controller. But unfortunately, the List changes took more time than I was expecting. So wait for it on a next update.
This week, I was able to add the following features to my recyclable list view project:
Check the Gallery.scene examples to see a Horizontal List with Fit Item to Viewport and Center on Item features enabled.
Happy Coding 🙂