Hierarchy 窗口会列出当前场景中的所有游戏对象。其中一些对象是资源文件的直接实例(如 3D 模型),其他则是预制件的实例,这是构成游戏大部分内容的自定义游戏对象。在场景中添加或删除游戏对象时(或在游戏机制添加和删除游戏对象时),这些游戏对象也会在 Hierarchy 窗口中显示和消失。
默认情况下,Hierarchy 窗口按创建顺序列出游戏对象,最新创建的游戏对象位于底部。可以通过向上或向下拖动游戏对象,或通过使游戏对象成为“子”或“父”游戏对象来对其重新排序(见下文)。
Unity 使用一种称为父子化的概念。创建一组游戏对象时,最顶层游戏对象或场景被称为“父游戏对象”,而在其下面分组的所有游戏对象被称为“子游戏对象”或“子项”。还可以创建嵌套的父子游戏对象(称为顶级父游戏对象的“后代”)。
单击父游戏对象的下拉箭头(位于其名称的左侧)可显示或隐藏其子项。在按住 Alt 键的同时单击下拉箭头可以切换父游戏对象的所有后代游戏对象(不仅仅包括直接子游戏对象)的可见性。
要使任何游戏对象成为另一对象的“子项”,请将目标子游戏对象拖放到 Hierarchy 窗口中的目标父游戏对象上。
还可以将游戏对象拖放到其他游戏对象旁边,使这些游戏对象成为“同级”:即同一父游戏对象下的子游戏对象。将游戏对象拖到现有游戏对象的上方或下方,直到出现水平蓝线,然后将游戏对象放下,即可将其放在现有游戏对象旁边。
子游戏对象会继承父游戏对象的移动和旋转。要了解与此相关的更多信息,请参阅关于变换组件的文档。
Hierarchy 窗口中游戏对象的顺序可以更改为字母数字顺序。在菜单栏中,选择 Edit > Preferences(在 Windows 中)或者选择 Unity > Preferences(在 OS X 中),启动 Preferences 窗口。选中 Enable Alpha Numeric Sorting。
选中此复选框时,Hierarchy 窗口的右上角会出现一个图标,允许在 Transform 排序(默认值)或 Alphabetic 排序之间切换。
Hierarchy 窗口中的场景可见性控件可用于在 Scene 视图中快速隐藏和显示游戏对象,而无需更改它们在游戏中的可见性。可见性控件旁边是场景拾取控件;拾取控件可在您进行编辑时阻止或允许在 Scene 视图中选择游戏对象。
这些控件在处理难以查看和选择特定游戏对象的大型或复杂场景时非常有用。
可以在 Hierarchy 窗口中同时打开多个场景。要查找与此相关的更多信息,请参阅多场景编辑页面。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.