FREE TRIAL

|

☀
☾
class

ListView

Inherits from UnityEngine.MonoBehaviour

Creates a virtualized, scrollable list of ItemView prefabs from a user-provided data source.

Properties

DataSourceItemCount

The size of the underlying data source. Will return 0 if the underlying data source is null.

MaxLoadedIndex

The highest index into the data source mapped to a list item that's currently loaded into view.

MinLoadedIndex

The lowest index into the data source mapped to a list item that's currently loaded into view.

OutOfViewDistance

The distance a list item must be out of view before it's removed and added back into the list item pool.
Can be used as a spatial buffer in the event the rendered size of a list item extends beyond its LayoutSize.

UIBlock

The parent UIBlock of all the list items. Attached to this.gameObject.

Methods

AddDataBinder

Subscribe to an indexed Data.OnBind<TData> event on this ListView's set of list items

AddDataUnbinder

Subscribe to an indexed Data.OnUnbind<TData> event on this ListView's set of list items

AddGestureHandler

Subscribe to an indexed IGestureEvent event on this ListView's set of list items

AddPrefabProvider

Register a PrefabProviderCallback<T> for a particular data type in the data source, TData.

GetDataSource

Retrieve the underlying data source, previously assigned via SetDataSource<T>(IList<T>).

JumpToIndex

Jumps the ListView to the item at the given index.

JumpToIndexPage

Jumps the ListView to the virtualized page of the item at the given index

Rebind

Reprocesses the object at index sourceIndex in the data source, invoking any necessary PrefabProviderCallback<T> callbacks, added via
AddPrefabProvider<TData>(PrefabProviderCallback<Int32>), and triggering a Data.OnBind<TData> event to refresh the list item content.

Refresh

Synchronizes the items in view with the content of the underlying data source, previously assigned via SetDataSource<T>(IList<T>).
Calls Rebind(Int32) for in-view elements, handles changes to the number of items in the data source, and will call Relayout() to ensure the view is filled.

Relayout

The ListView will pull more content into view and page content out of view as it's scrolled, but it doesn't automatically check for external
events causing its child list items to change in size. This utility provides a way to manually re-fill the list view or page out extraneous list items.

RemoveDataBinder

Unsubscribe from an indexed Data.OnBind<TData> event previously subscribed to via AddDataBinder<TData, TVisuals>(UIEventHandler<Data.OnBind<TData>, TVisuals, Int32>)

RemoveDataUnbinder

Unsubscribe from an indexed Data.OnUnbind<TData> event previously subscribed to via AddDataUnbinder<TData, TVisuals>(UIEventHandler<Data.OnUnbind<TData>, TVisuals, Int32>)

RemoveGestureHandler

Unsubscribe from a gesture event previously subscribed to via AddGestureHandler<TEvent, TVisuals>(UIEventHandler<TEvent, TVisuals, Int32>)

RemovePrefabProvider

Unregister a PrefabProviderCallback<T> that was previously registered via AddPrefabProvider<TData>(PrefabProviderCallback<Int32>)

Scroll

Scrolls the list content by the provided delta along the UIBlock's AutoLayout.Axis

SetDataSource

Set the underlying data source. This instructs the list to start creating a 1-to-1 mapping of objects in the data source to ListView list items.

TryDetach (2 overloads)
  1. Transfers ownership of the ItemView representing the object at data source index sourceIndex from the ListView to the caller, allowing the caller to manipulate the listItem arbitrarily without fighting the ListView binding/prefab pooling system.
  2. Transfers ownership of the detached listItem from the ListView to the caller, allowing the caller to manipulate the listItem arbitrarily without fighting the ListView binding/prefab pooling system.
TryGetItemView

Attempts to retrieve the ItemView in view representing the object in the data source at the provided index, sourceIndex.

TryGetSourceIndex

Attempts to retrieve the index into the data source, sourceIndex, represented by the provided in-view listItem.

TryReattach

If a list item was previously detached from the ListView (via TryDetach(ItemView, Transform)), this is a way to transfer ownership of listItem back to the ListView.

Events

OnScrolledPastEnd

Invoked when the list is scrolled beyond the last list element. Provides the distance between the edge of content and edge of the viewport.

OnScrolledPastStart

Invoked when the list is scrolled beyond the first list element. Provides the distance between the edge of content and edge of the viewport.

☀
☾
In This Article
Legal EmailContact Github
Copyright © 2022 Supernova Technologies, LLC