Scripting API

BaseVerticalCollectionView

class in UnityEngine.UIElements · UnityEngine.UIElementsModule · inherits from BindableElement

50 of 50 of Unity's membersUnity's documentation
In Tassix

A vertical list of items made by makeItem and filled by bindItem for each entry of itemsSource, in a scroll view, with selection. Items are made when the view next updates after the source or callbacks change (RefreshItems and Rebuild bind or remake them then).

Fields 9

static readonly string borderUssClassName
static readonly string dragHoverBarUssClassName
static readonly string dragHoverMarkerUssClassName
static readonly string itemAlternativeBackgroundUssClassName
static readonly string itemDragHoverUssClassName
static readonly string itemSelectedVariantUssClassName
static readonly string itemUssClassName
static readonly string listScrollViewUssClassName
static readonly string ussClassName

Properties 21

Action<VisualElement, int>? bindItem { get; set; }
VisualElement contentContainer { get; }
Action<VisualElement>? destroyItem { get; set; }
float fixedItemHeight { get; set; }
bool horizontalScrollingEnabled { get; set; }
int itemHeight { get; set; }
IList? itemsSource { get; set; }
Func<VisualElement>? makeItem { get; set; }
bool reorderable { get; set; }

Items can be dragged to new places.

float resolvedItemHeight { get; }
IEnumerable<int> selectedIds { get; }
int selectedIndex { get; set; }
IEnumerable<int> selectedIndices { get; }
object? selectedItem { get; }
IEnumerable<object> selectedItems { get; }
SelectionType selectionType { get; set; }
AlternatingRowBackground showAlternatingRowBackgrounds { get; set; }
bool showBorder { get; set; }
Action<VisualElement, int>? unbindItem { get; set; }
CollectionViewController viewController { get; }

The controller of the view's items (made by CreateViewController).

CollectionVirtualizationMethod virtualizationMethod { get; set; }

Methods 16

void AddToSelection(int index)
void ClearSelection()
VisualElement? GetRootElementForId(int id)
VisualElement? GetRootElementForIndex(int index)

The item showing an index, or null when it's out of view.

void Rebuild()

Makes the items again (destroying the old ones) and binds them.

void Refresh()
void RefreshItem(int index)
void RefreshItems()

Binds the items again (to their indices' entries), as many as the view now needs.

void RemoveFromSelection(int index)
void ScrollTo(VisualElement visualElement)
void ScrollToId(int id)
void ScrollToItem(int index)

Scrolls an item into view (-1: the last): up to its top when above, else down until it shows at the bottom, which with fixed heights goes one item further, as Unity's does.

void ScrollToItemById(int id)
void SetSelection(int index)
void SetSelection(IEnumerable<int> indices)
void SetSelectionWithoutNotify(IEnumerable<int> indices)
void SetViewController(CollectionViewController controller)

Events 12

event Func<CanStartDragArgs, bool>? canStartDrag

Asked when an item is pressed: false keeps it from being dragged.

event Func<HandleDragAndDropArgs, DragVisualMode>? dragAndDropUpdate

While a drag is over the view: how it shows (Rejected or None: it can't drop here).

event Func<HandleDragAndDropArgs, DragVisualMode>? handleDrop

On a drop: handles it instead of the default (moving the dragged items there).

event Action<int, int>? itemIndexChanged
event Action<IEnumerable<object>>? itemsChosen
event Action? itemsSourceChanged
event Action<IEnumerable<object>>? onItemsChosen
event Action<IEnumerable<int>>? onSelectedIndicesChange
event Action<IEnumerable<object>>? onSelectionChange
event Action<IEnumerable<int>>? selectedIndicesChanged
event Action<IEnumerable<object>>? selectionChanged
event Func<SetupDragAndDropArgs, StartDragArgs>? setupDragAndDrop

When a drag starts: the drag's settings (title, data), changed or as given.