# TreeViewItem

> The TreeViewItem is used to build the tree representation of a tree data structure.

## Definition

* **Type:** Class
* **Namespace:** [UnityEditor.IMGUI.Controls](/engine/6000.0/script-reference/unityeditor/imgui/controls.md)
* **Assembly:** UnityEditor
* **Implements:** [IComparable\<TreeViewItem>](https://learn.microsoft.com/dotnet/api/system.icomparable-1)

```csharp
public class TreeViewItem : IComparable<TreeViewItem>
```

## Remarks

The TreeViewItem can be derived from to add custom data.

Additional Resources: [TreeView](/engine/6000.0/script-reference/unityengine/uielements/treeview.md).

## Constructors

| Constructor                                                                                                                                                             | Description               |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
| [TreeViewItem()](/engine/6000.0/script-reference/unityeditor/imgui/controls/treeviewitem/ctor.md#treeviewitem\(\))                                                      | TreeViewItem constructor. |
| [TreeViewItem(System.Int32)](/engine/6000.0/script-reference/unityeditor/imgui/controls/treeviewitem/ctor.md#treeviewitem\(int\))                                       | TreeViewItem constructor. |
| [TreeViewItem(System.Int32,System.Int32)](/engine/6000.0/script-reference/unityeditor/imgui/controls/treeviewitem/ctor.md#treeviewitem\(int-int\))                      | TreeViewItem constructor. |
| [TreeViewItem(System.Int32,System.Int32,System.String)](/engine/6000.0/script-reference/unityeditor/imgui/controls/treeviewitem/ctor.md#treeviewitem\(int-int-string\)) | TreeViewItem constructor. |

## Properties

| Property                                                                                              | Description                                                                                                                                 |
| ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| [children](/engine/6000.0/script-reference/unityeditor/imgui/controls/treeviewitem/children.md)       | The list of child items of this TreeViewItem.                                                                                               |
| [depth](/engine/6000.0/script-reference/unityeditor/imgui/controls/treeviewitem/depth.md)             | The depth refers to how many ancestors this item has, and corresponds to the number of horizontal ‘indents’ this item has.                  |
| [displayName](/engine/6000.0/script-reference/unityeditor/imgui/controls/treeviewitem/displayname.md) | Name shown for this item when rendered.                                                                                                     |
| [hasChildren](/engine/6000.0/script-reference/unityeditor/imgui/controls/treeviewitem/haschildren.md) | Returns true if [TreeViewItem.children](/engine/6000.0/script-reference/unityeditor/imgui/controls/treeviewitem/children.md) has any items. |
| [icon](/engine/6000.0/script-reference/unityeditor/imgui/controls/treeviewitem/icon.md)               | If set, this icon will be rendered to the left of the displayName. The icon is rendered at 16x16 points by default.                         |
| [id](/engine/6000.0/script-reference/unityeditor/imgui/controls/treeviewitem/id.md)                   | Unique ID for an item.                                                                                                                      |
| [parent](/engine/6000.0/script-reference/unityeditor/imgui/controls/treeviewitem/parent.md)           | The parent of this TreeViewItem. If it is null then it is considered the root of the TreeViewItem tree.                                     |

## Methods

| Method                                                                                          | Description                                                                                                                                                                                                            |
| ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AddChild](/engine/6000.0/script-reference/unityeditor/imgui/controls/treeviewitem/addchild.md) | Helper method that adds the `child` TreeViewItem to the [TreeViewItem.children](/engine/6000.0/script-reference/unityeditor/imgui/controls/treeviewitem/children.md) list and sets the parent property on the `child`. |
