All Projects → sinbad → Unityrecyclinglistview

sinbad / Unityrecyclinglistview

Licence: mit
A fast scrolling list component for Unity UI which recycles its child elements

Projects that are alternatives of or similar to Unityrecyclinglistview

Uicard
Generic UI for card games like Hearthstone, Magic Arena and Slay the Spire...
Stars: ✭ 142 (+65.12%)
Mutual labels:  unity, unity3d, ui-components
Akvj
Demo project for Akvfx (Azure Kinect plugin for Unity)
Stars: ✭ 79 (-8.14%)
Mutual labels:  unity, unity3d
Vertexanimationjob
Vertex animation with C# Job System and new Mesh API
Stars: ✭ 82 (-4.65%)
Mutual labels:  unity, unity3d
Dlibfacelandmarkdetector
FaceLandmark Detector using Dlib (Unity Asset Plugin)
Stars: ✭ 80 (-6.98%)
Mutual labels:  unity, unity3d
3dxrayshader unity
Surface shader. Clips a Model with given plane , applies fresnel on clipped part and highlights the cross section.
Stars: ✭ 73 (-15.12%)
Mutual labels:  unity, unity3d
Weaver
Weaver is a code weaving framework built right into Unity Engine. Based heavily off of Fody.
Stars: ✭ 78 (-9.3%)
Mutual labels:  unity, unity3d
Unitycsvutil
Lightweight but type safe CSV serialise/deserialise of objects
Stars: ✭ 80 (-6.98%)
Mutual labels:  unity, unity3d
Davinci
An esay-to-use image downloading and caching library for Unity
Stars: ✭ 74 (-13.95%)
Mutual labels:  unity, unity3d
1 Character Movement
The first section of the course. You will learn everything required to build a simple movement system in your RPG, creating the core experience. http://gdev.tv/rpggithub
Stars: ✭ 81 (-5.81%)
Mutual labels:  unity, unity3d
Shapes2d
Shapes2D for Unity3D - Make simple art assets quickly in Unity
Stars: ✭ 83 (-3.49%)
Mutual labels:  unity, unity3d
Unity Azure Pipelines Tasks
Azure DevOps extension adding tools to build and deploy Unity 3D projects using Azure Pipelines
Stars: ✭ 83 (-3.49%)
Mutual labels:  unity, unity3d
Temporalreprojectionexample
Temporal reprojection example for Unity
Stars: ✭ 82 (-4.65%)
Mutual labels:  unity, unity3d
Bdframework.core
[中]Simple! Easy! Powerful Unity3d game workflow! Unity3d framework:c# hotfix(ILRuntime)、asset manager、ui workflow、network debug... and so on
Stars: ✭ 1,196 (+1290.7%)
Mutual labels:  unity, unity3d
Unityandroidhotupdate
(Unity3D热更新) provide a way to hot update Unity app on Android, support code&resources, not need lua js or IL runtime etc..., will not disturb your project development; just loading the new version apk file to achieve.
Stars: ✭ 85 (-1.16%)
Mutual labels:  unity, unity3d
Unity3d Dynamicallyloadinganimation
👾 Unity3D Loading and unloading animations at runtime (Example)
Stars: ✭ 74 (-13.95%)
Mutual labels:  unity, unity3d
Fancyscrollview
[Unity] A scrollview component that can implement highly flexible animations.
Stars: ✭ 1,216 (+1313.95%)
Mutual labels:  unity, unity3d
Unity Abstract Wire
Unity Abstract Wires Effect
Stars: ✭ 83 (-3.49%)
Mutual labels:  unity, unity3d
Nexplayer unity plugin
Stream videos in HLS & DASH with Widevine DRM using NexPlayer Video Streaming Player SDK for Unity on Android & iOS devices
Stars: ✭ 73 (-15.12%)
Mutual labels:  unity, unity3d
Dkvfxsketches
VFX sketches with Depthkit and Unity
Stars: ✭ 74 (-13.95%)
Mutual labels:  unity, unity3d
Atlasimage
AtlasImage is a graphic component use SpriteAtlas for uGUI. In addition, add useful sprite selector and border editor to the inspector.
Stars: ✭ 81 (-5.81%)
Mutual labels:  unity, unity3d

RecyclingListView for Unity

What is this for?

One way of making a list is simply to create every item in the list and add it to the content view of a Unity ScrollRect, perhaps with a ContentFitter to automatically expand it, and a VerticalLayoutGroup to position them. There's one problem with this: it gets really slow at high volumes.

Most UI systems don't do this under the hood; instead they only allocate just enough visual resources to cover the visible area (plus a safety area), and then recycle the child views as you scroll - views which drop out of view are re-used for the parts that are just coming into view. This way you have a fixed amount of overheads regardless of how big your list is.

This repo contains a smallest-possible implementation of this concept, sometimes called "virtualising" a list or just "recycling". Basically you keep the "model" which contains all of the data, and the list calls you back to ask you to provide details of a specific element when it needs it, because it's coming into view.

Example Image

How to use it

The Demo

You can drag this whole repo into Unity Assets to provide a quick demo of this so you can pick it apart yourself, just load Scenes/RecyclingList.

How it works

  • You have a list of items (just data, no view), this is your Model. This can be on any class.
  • You create a ScrollRect (Scroll View in the menu) and add a RecyclingListView to it
  • You create a prefab which is a child item in your list (the View item). It must have a component of RecyclingListViewItem on it.
  • You give the RecyclingListView a reference to that prefab; it pre-allocates them and keeps them in a pool
  • You set a delegate on RecyclingListView which is the method it calls when one of these items needs populating with data
  • You simply tell the RecyclingListView the RowCount of your Model. It then calls the delegate for any of those items in view, giving you a row index to refer to.
  • You can tell the view that the model has been updated (without changing its size) via Refresh if need be (either completely or for a subset)

Step by step

  1. Create a Canvas
  2. Create a Scroll View underneath
  3. Tune how you like (I removed the horizontal scroll bar)
  4. Add RecyclingListView component to the scroll view
  5. Create a child panel which will go inside the scroll view, temporarily inside Content of scroll view (just so you can get it looking like you want)
  6. Create a subclass of RecyclingListViewItem to hold whatever data you need for this view
  7. Add your RecyclingListViewItem subclass as a component to the root of the child
  8. Make a prefab out of this child panel, then delete it from content
  9. Select the scroll view and set the Child Prefab on RecyclingListView to your prefab
  10. Create your component which will contain the model, somewhere. It doesn't matter where, so long as it has a reference to the RecyclingListView
  11. Your model component should set RecyclingListView.ItemCallback, and set RecyclingListView.RowCount. The rest will happen mostly automatically as "How it works" above.
  12. Change RowCount when you alter the length of the list, or Clear() and Refresh() to empty or update content in-place.

Limitations

This is not a general purpose grid view like you'll find in the Asset Store, it's just for lists. Specifically:

  • Only one type of child panel is supported
  • The child panel has to be a fixed height
  • Horizontal scrolling can still be used, but virtualisation is only done vertically

Tips

Pre-Allocate More Items

The list handles dynamic resizing, but if you know the max height your content view can ever be, and that's likely to be bigger than the default size, you can avoid some reallocation by specifying that height in the "Pre Alloc Height" property on the list view component.

License (MIT)

Copyright (c) 2019 Steve Streeting

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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].