Version: 2019.2
Game 视图
Inspector 窗口

Hierarchy 窗口

打开 Unity 新项目时的默认 Hierarchy 窗口视图
打开 Unity 新项目时的默认 Hierarchy 窗口视图

The Hierarchy window contains a list of every GameObject in the current Scene. Some of these are direct instances of Asset files (like 3D models), and others are instances of Prefabs, which are custom GameObjects that make up most of your game. When you add or remove GameObjects the Scene (or when your gameplay mechanic adds and removes them), they appear and disappear from the Hierarchy as well. By default, the Hierarchy window lists GameObjects by order of creatin, with the most recently created GameObjects at the the bottom. You can re-order the GameObjects by dragging them up or down, or by making them “child” or “parent” GameObjects (see below).

父子化

Unity 使用一种称为父子化的概念。创建一组游戏对象时,最顶层游戏对象或场景被称为“父游戏对象”,而在其下面分组的所有游戏对象被称为“子游戏对象”或“子项”。还可以创建嵌套的父子游戏对象(称为顶级父游戏对象的“后代”)。

In this image, Child and Child 2 are the child GameObjects of Parent. Child 3 is a child GameObject of Child 2, and a descendant GameObject of Parent.
In this image, Child and Child 2 are the child GameObjects of Parent. Child 3 is a child GameObject of Child 2, and a descendant GameObject of Parent.

单击父游戏对象的下拉箭头(位于其名称的左侧)可显示或隐藏其子项。在按住 Alt 键的同时单击下拉箭头可以切换父游戏对象的所有后代游戏对象(不仅仅包括直接子游戏对象)的可见性。

设定子游戏对象

要使任何游戏对象成为另一对象的“子项”,请将目标子游戏对象拖放到 Hierarchy 窗口中的目标父游戏对象上。

在此图中,Object 4(选定对象)被拖到目标父游戏对象 Object 1(以蓝色胶囊形状突出显示)上。
在此图中,Object 4(选定对象)被拖到目标父游戏对象 Object 1(以蓝色胶囊形状突出显示)上。

还可以将游戏对象拖放到其他游戏对象旁边,使这些游戏对象成为“同级”:即同一父游戏对象下的子游戏对象。将游戏对象拖到现有游戏对象的上方或下方,直到出现水平蓝线,然后将游戏对象放下,即可将其放在现有游戏对象旁边。

In this image, Object 4 (selected) is being dragged between Object 2 and Object 3 (indicated by the blue horizontal line), to be placed here as a sibling of these two GameObjects under the parent GameObject Object 1 (highlighted in a blue capsule).
In this image, Object 4 (selected) is being dragged between Object 2 and Object 3 (indicated by the blue horizontal line), to be placed here as a sibling of these two GameObjects under the parent GameObject Object 1 (highlighted in a blue capsule).

子游戏对象会继承父游戏对象的移动和旋转。要了解与此相关的更多信息,请参阅关于变换组件的文档。

字母数字排序

Hierarchy 窗口中游戏对象的顺序可以更改为字母数字顺序。在菜单栏中,选择 Edit > Preferences(在 Windows 中)或者选择 Unity > Preferences(在 OS X 中),启动 Preferences 窗口。选中 Enable Alpha Numeric Sorting

选中此复选框时,Hierarchy 窗口的右上角会出现一个图标,允许在 Transform 排序(默认值)或 Alphabetic 排序之间切换。

Toggling Scene Visibility

The Scene visibility controls in the Hierarchy window allow you to quickly hide and show GameObjects in the Scene view without changing their in-game visibility. This is useful for working with large or complex Scenes where it can be difficult to view and select specific GameObjects.

Scene visibility icons/toggles
Scene visibility icons/toggles

如需了解更多信息,请参阅场景可见性文档。

多场景编辑

可以在 Hierarchy 窗口中同时打开多个场景。要查找与此相关的更多信息,请参阅多场景编辑页面。


  • 2019–01–30 页面已修订

  • Toggling Scene Visibility added in 2019.1 NewIn20191

Game 视图
Inspector 窗口