Version: 2020.2
Game 视图
Inspector 窗口

Hierarchy 窗口

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

The Hierarchy window contains a list of every GameObject in the current Scene. Some of these GameObjects 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 application. When you add or remove GameObjects to or from the Scene (or when your gameplay mechanic adds or removes them), they appear and disappear from the Hierarchy.

By default, the Hierarchy window lists GameObjects by order of creation, with the most recently created GameObjects at 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 uses a concept called Parenting. When you create a group of GameObjects, the topmost GameObject or Scene is called the “parent GameObject”, and all GameObjects grouped underneath it are called “child GameObjects”. You can also create nested parent-child GameObjects (called “descendants” of the top-level parent GameObject).

在此图中,Child 和 Child 2 是 Parent 的子游戏对象。Child 3 是 Child 2 的子游戏对象,也是 Parent 的后代游戏对象。
在此图中,ChildChild 2Parent 的子游戏对象。Child 3Child 2 的子游戏对象,也是 Parent 的后代游戏对象。

On the left-hand side of a parent GameObject’s name, click its drop-down arrow to show or hide its child GameObjects. Hold down the Alt key while clicking the drop-down arrow to toggle visibility of the parent’s descendant GameObjects, in addition to the immediate child GameObject.

设定子游戏对象

To make any GameObject the child of another, drag and drop the intended child GameObject onto the intended parent GameObject in the Hierarchy.

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

You can also drag-and-drop an GameObject alongside other GameObjects to make them “siblings”: that is, child GameObjects under the same parent GameObject. Drag the GameObject above or below an existing GameObject until a horizontal blue line appears, and drop it there to place it alongside the existing GameObject.

在此图中,Object 4(选定对象)被拖动到 Object 2 与 Object 3 之间(以蓝色水平线指示),从而作为这两个游戏对象的同级而放置在父游戏对象 Object 1(以蓝色胶囊形状突出显示)之下。
在此图中,Object 4(选定对象)被拖动到 Object 2Object 3 之间(以蓝色水平线指示),从而作为这两个游戏对象的同级而放置在父游戏对象 Object 1(以蓝色胶囊形状突出显示)之下。

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

Default parent

You can make any GameObject in the Hierarchy window a “default parent”. When you drag a GameObject into the Scene view, Unity automatically makes this GameObject the child of the GameObject you set as the default parent.

To make a GameObject a default parent:

  1. In the Hierarchy window, right-click on the GameObject
  2. Select Set as Default Parent

When you drag a GameObject into the Scene view, in the Hierarchy window, the child GameObject is indented below the default parent GameObject. The name of the default parent GameObject is bold.

In this image, the Cube GameObject is the default parent. When the user drags the Car GameObject into the Scene view, Unity automatically makes it the child of the Cube GameObject.
In this image, the Cube GameObject is the default parent. When the user drags the Car GameObject into the Scene view, Unity automatically makes it the child of the Cube GameObject.

To remove default parent status from a GameObject:

  1. In the Hierarchy window, right-click on the GameObject
  2. Select Clear Default Parent

The name of the GameObject that was previously the default parent is no longer bold. When you drag a GameObject into the Scene view, it appears at the top level in the Hierarchy window. In other words, Unity does not make this GameObject the child of the GameObject that was previously the default parent.

In this image, no GameObjects in the Hierarchy window are set as the default parent. When the user drags the Car GameObject into the Scene view, Unity adds it at the top level of the hierarchy.
In this image, no GameObjects in the Hierarchy window are set as the default parent. When the user drags the Car GameObject into the Scene view, Unity adds it at the top level of the hierarchy.

You can only set one default parent per Scene. In the Hierarchy window, if you set a GameObject as the default parent, and then you make a different GameObject in the same Scene the default parent, only the second GameObject is the default parent.

If you have multiple Scenes in the Hierarchy window, and you set default parents in each Scene, when you drag a GameObject into the Scene view, Unity makes the default parent GameObject in the active Scene the parent of the new GameObject.

In this image, the Cube GameObjects in both Scene1 and Scene2 are set as default parents. Unity sets the Cube in Scene1 as the parent of the Car GameObject, because Scene1 is the active Scene.
In this image, the Cube GameObjects in both Scene1 and Scene2 are set as default parents. Unity sets the Cube in Scene1 as the parent of the Car GameObject, because Scene1 is the active Scene.

You can set a keyboard shortcut for the default parent setting in the Shortcuts manager. On the Shortcuts window, assign a keyboard shortcut to Hierarchy View > Set as Default Parent. If there is no default parent set, and in the Hierarchy window you select a GameObject, use the shortcut to make this GameObject the default parent. When a default parent is set, use the shortcut to remove default parent status from any GameObject that has it.

字母数字排序

GameObjects in the Hierarchy window can be sorted in alphanumeric order. In the menu bar, select Edit > Preferences in Windows or Unity > Preferences in macOS to launch the Preferences window. Enable Enable Alpha Numeric Sorting.

When you enable Enable Alpha Numeric Sorting, an icon appears in the top-right of the Hierarchy window, allowing you to toggle between Transform sorting (the default value) or Alphabetic sorting.

设置游戏对象的可见性和可拾取性

In the Hierarchy window, the Scene visibility controls allow you to hide and show GameObjects in the Scene view without changing their in-application visibility. The Scene picking controls are next to the Scene Visibility controls. Use the Scene picking controls to toggle between blocking and allowing you to select GameObjects in the Scene view while you are editing.

When working with large or complex Scenes, these controls make it easier to view and select specific GameObjects.

场景可见性图标/开关
场景可见性图标/开关

有关更多信息,请参阅场景可见性场景拾取文档。

多场景编辑

In the Hierarchy window, you can have more than one Scene open at the same time. To find out more about this, see the Multi Scene Editing page.


  • 在 Unity 2019.1 中添加了“切换场景可见性”NewIn20191
  • 在 Unity 2019.3 中添加了“切换场景可拾取性”NewIn20193
Game 视图
Inspector 窗口