Recycle Scrollview



Endless scrolling!



In the default Unity3D UI, there is a a scrollview that you can make use of but it lacks a 'recycle' functionality. If you want to display 100 items, you have to instantiate 100 items. Which is 'maybe oke' for 100 items but its not very scalable since it will get slower with every new item you add to the list. So I created my own RecycleScrollView.

I only show visible items(+2 extra, top and bot) and use a Mask to clear the edges. Very simple stuff.

In the next example we have list of 5000+ items:







At one point I want to include a scrollbar in the ScrollView<T> class. Now it is up to the user to create one and implement the scrolling. I also want the IItemAdapter.Adapt method to include the index of the item, so that I can sand that back in ChapterAdapter.



Code for the scrollview is set up to be generic. It requires a rectTransform to put everything in, this will also be the bounds for the scrollview. It needs a prefab of the item that will be shown and it requires an adapter that will fill in an item with the correct information from generic type.







Keep in mind that this is unfinished, there are more text components that need to be filled out later so I already use GetComponentsInChildren<T>().