#unity/日常积累 # TreeViewItem class in UnityEditor.IMGUI.Controls ## 描述 TreeViewItem 用于构建树数据结构的树形表示。 可以派生 TreeViewItem 来添加自定义数据。 另请参阅:[TreeView](https://docs.unity.cn/cn/2020.3/ScriptReference/IMGUI.Controls.TreeView.html)。 ## 变量 [children](https://docs.unity.cn/cn/2020.3/ScriptReference/IMGUI.Controls.TreeViewItem-children.html) 此 TreeViewItem 的子项列表。 [depth](https://docs.unity.cn/cn/2020.3/ScriptReference/IMGUI.Controls.TreeViewItem-depth.html) 深度指的是此项具有的父级数量,与此项具有的水平“缩进”数量相对应。 [displayName](https://docs.unity.cn/cn/2020.3/ScriptReference/IMGUI.Controls.TreeViewItem-displayName.html) 渲染此项时显示的名称。 [hasChildren](https://docs.unity.cn/cn/2020.3/ScriptReference/IMGUI.Controls.TreeViewItem-hasChildren.html) 如果 children 有任何项,则返回 true。 [icon](https://docs.unity.cn/cn/2020.3/ScriptReference/IMGUI.Controls.TreeViewItem-icon.html) 如果已设置,此图标将渲染到 displayName 的左侧。默认情况下,此图标以 16x16 点渲染。 [id](https://docs.unity.cn/cn/2020.3/ScriptReference/IMGUI.Controls.TreeViewItem-id.html) 项的唯一 ID。 [parent](https://docs.unity.cn/cn/2020.3/ScriptReference/IMGUI.Controls.TreeViewItem-parent.html) 此 TreeViewItem 的父项。如果它为 null,则会被视为 TreeViewItem 树的根。 ## 构造函数 [TreeViewItem](https://docs.unity.cn/cn/2020.3/ScriptReference/IMGUI.Controls.TreeViewItem-ctor.html) TreeViewItem 构造函数。 ## 公共函数 [AddChild](https://docs.unity.cn/cn/2020.3/ScriptReference/IMGUI.Controls.TreeViewItem.AddChild.html) 将 child TreeViewItem 添加到 children 列表并在 child 上设置父属性的 helper 方法。