Class ListViewController<TData, TItem, TIndex>
Core class of the list view framework The list view controller and its variants provide a starting point for scrollable list views which update a set of visible items once per frame based on a list of data objects. Extensions of this class will determine behavior like whether to scroll vertically or horizontally, or whether to present list items in a grid.
Inheritance
Inherited Members
Namespace: Unity.ListViewFramework
Syntax
public abstract class ListViewController<TData, TItem, TIndex> : ListViewControllerBase, IScrollHandler, IEventSystemHandler where TData : class, IListViewItemData<TIndex> where TItem : class, IListViewItem<TData, TIndex>
Type Parameters
Name | Description |
---|---|
TData | The type of object in the list of data |
TItem | The base type of all list items |
TIndex | The type which is used as a unique index to map data to list items |
Fields
m_Data
The list of data
Declaration
protected List<TData> m_Data
Field Value
Type | Description |
---|---|
List<TData> |
m_GrabbedRows
Items which are currently "grabbed" and temporarily removed from the list
Declaration
protected readonly Dictionary<TIndex, Transform> m_GrabbedRows
Field Value
Type | Description |
---|---|
Dictionary<TIndex, Transform> |
m_ListItems
The currently-visible list items
Declaration
protected readonly Dictionary<TIndex, TItem> m_ListItems
Field Value
Type | Description |
---|---|
Dictionary<TIndex, TItem> |
m_TemplateDictionary
A dictionary for providing constant-time access to ListViewItemTemplates based on the name of the template prefab
Declaration
protected readonly Dictionary<string, ListViewItemTemplate<TItem>> m_TemplateDictionary
Field Value
Type | Description |
---|---|
Dictionary<String, ListViewItemTemplate<TItem>> |
Properties
data
The list of data
Declaration
public virtual List<TData> data { get; set; }
Property Value
Type | Description |
---|---|
List<TData> |
listHeight
The total height of all list rows, used to determine the maximum amount of scroll offset before snapping back
Declaration
protected override float listHeight { get; }
Property Value
Type | Description |
---|---|
Single |
Overrides
multiSelectMode
Converts the List View Item into a multiselect mode, for use with combined actions
Declaration
protected bool multiSelectMode { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
Awake()
Called when the script instance is being loaded
Declaration
protected override void Awake()
Overrides
GetGrabbedRow(Transform)
Get a list item grabbed by the given ray origin
Declaration
protected virtual TItem GetGrabbedRow(Transform rayOrigin)
Parameters
Type | Name | Description |
---|---|---|
Transform | rayOrigin | The ray origin used to grab a list item |
Returns
Type | Description |
---|---|
TItem | The item which is grabbed |
GetListItem(TIndex)
Get the list item for a given index
Declaration
protected TItem GetListItem(TIndex index)
Parameters
Type | Name | Description |
---|---|---|
TIndex | index | The index of the list item |
Returns
Type | Description |
---|---|
TItem | The item, if one exists |
GetNewItem(TData, out TItem)
Get a view item for a given datum, either from its template's pool, or by creating a new one
Declaration
protected virtual bool GetNewItem(TData datum, out TItem item)
Parameters
Type | Name | Description |
---|---|---|
TData | datum | The datum for the desired view item |
TItem | item | The view item |
Returns
Type | Description |
---|---|
Boolean | True if a new item was instantiated, false if the view item came from the item pool |
HasData()
Check whether the m_Data array is null
Declaration
protected override sealed bool HasData()
Returns
Type | Description |
---|---|
Boolean | True if m_Data is not null |
Overrides
InstantiateItem(TData)
Instantiate the list item for a given datum
Declaration
protected virtual TItem InstantiateItem(TData datum)
Parameters
Type | Name | Description |
---|---|---|
TData | datum | The datum for a list item |
Returns
Type | Description |
---|---|
TItem | The instantiated list item |
Recycle(TIndex)
Recycle a list item by index
Declaration
protected virtual void Recycle(TIndex index)
Parameters
Type | Name | Description |
---|---|---|
TIndex | index | The index of the list item to be recycled |
RecycleItem(String, TItem)
Recycle a list item into its template's pool
Declaration
protected virtual void RecycleItem(string template, TItem item)
Parameters
Type | Name | Description |
---|---|---|
String | template | The template of this list item |
TItem | item | The list item |
SetMultiSelectMode(Boolean)
Override and call base function to add custom behaviour when entering or exiting multiselect mode.
Declaration
protected virtual void SetMultiSelectMode(bool mode)
Parameters
Type | Name | Description |
---|---|---|
Boolean | mode | If true, multi-select is enabling, false otherwise. |
SetRowGrabbed(TIndex, Transform, Boolean)
Set the grabbed state of the list item at a given index
Declaration
protected virtual void SetRowGrabbed(TIndex index, Transform rayOrigin, bool grabbed)
Parameters
Type | Name | Description |
---|---|---|
TIndex | index | The index of the list item/data |
Transform | rayOrigin | The ray origin used to grab this list item |
Boolean | grabbed | Whether the item is grabbed or not |
Start()
Called on the frame when a script is enabled just before any of the Update methods are called the first time
Declaration
protected virtual void Start()
UpdateItem(IListViewItem, Int32, Single, Boolean, ref Boolean)
Update a single item
Declaration
protected override void UpdateItem(IListViewItem item, int order, float offset, bool dontSettle, ref bool doneSettling)
Parameters
Type | Name | Description |
---|---|---|
IListViewItem | item | The item to update |
Int32 | order | The order of this item, among the other visible items |
Single | offset | The offset at which to position this item |
Boolean | dontSettle | Whether to bypass settling behavior |
Boolean | doneSettling | Whether all items are done settling |
Overrides
UpdateItems()
Called by UpdateView to update the list items
Declaration
protected override void UpdateItems()
Overrides
UpdateVisibleItem(TData, Int32, Single, ref Boolean)
Update a visible list item
Declaration
protected virtual TItem UpdateVisibleItem(TData datum, int order, float offset, ref bool doneSettling)
Parameters
Type | Name | Description |
---|---|---|
TData | datum | The datum representing this list item |
Int32 | order | The order of this item, among the other visible items |
Single | offset | The offset at which to position this item |
Boolean | doneSettling | Whether all items are done settling |
Returns
Type | Description |
---|---|
TItem | The item associated with this datum |