Scripting API

BaseTreeView

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

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

A collection view of a tree: its rows are the items whose parents are all expanded, each shown with indents for its depth, a toggle (hidden without children) that expands it, and the item made by makeItem. Selection follows the items' ids across rows changing.

Fields 8

static readonly BindingId autoExpandProperty
static readonly int invalidId
static readonly string itemContentContainerUssClassName
static readonly string itemIndentUssClassName
static readonly string itemIndentsContainerUssClassName
static readonly string itemToggleUssClassName
static readonly string itemUssClassName
static readonly string ussClassName

Properties 3

bool autoExpand { get; set; }
IList? itemsSource { get; }

The rows shown: the ids of the items whose parents are all expanded, in order.

BaseTreeViewController? viewController { get; }

The tree's controller: none until SetRootItems makes one for the items' type.

Methods 21

void AddItem<T>(TreeViewItemData<T> item, int parentId = -1, int childIndex = -1, bool rebuildTree = true)

Adds an item under a parent (-1: a root) at a child index (-1: last).

void AddToSelectionById(int id)
void CollapseAll()
void CollapseItem(int id, bool collapseAllChildren = false, bool refresh = true)
void ExpandAll()
void ExpandItem(int id, bool expandAllChildren = false, bool refresh = true)
void ExpandRootItems()
IEnumerable<int> GetChildrenIdsForIndex(int index)
int GetIdForIndex(int index)
T GetItemDataForId<T>(int id)
T GetItemDataForIndex<T>(int index)
int GetParentIdForIndex(int index)
IEnumerable<int> GetRootIds()
IEnumerable<TreeViewItemData<T>> GetSelectedItems<T>()
int GetTreeCount()
bool IsExpanded(int id)
void RemoveFromSelectionById(int id)
void SetRootItems<T>(IList<TreeViewItemData<T>> rootItems)
void SetSelectionById(int id)
void SetSelectionById(IEnumerable<int> ids)
void SetSelectionByIdWithoutNotify(IEnumerable<int> ids)
bool TryRemoveItem(int id, bool rebuildTree = true)

Removes an item and its children; false when there's no such item.

Events 1

event Action<TreeViewExpansionChangedArgs>? itemExpandedChanged