Unity’s scene visibility controls allow you to quickly hide and display 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 视图。这意味着不会从渲染的场景中意外删除游戏对象或触发光照、遮挡和其他系统的不必要烘焙作业。
The Editor saves Scene visibility settings to a file called SceneVisibilityState.asset
in the Project’s Library
folder. The scene reads from this file and updates it automatically whenever you change the visibility settings. This makes it possible for your settings to persist from one session to the next. Because source control setups for Unity typically ignore the Library
folder, changing visibility settings should not create source control conflicts.
You can set visibility on specific scene items in the Hierarchy window, but if the scene-wide visibility setting is disabled, items marked as hidden might still appear in the Scene view. To change this setting, you can toggle Scene visibility on the Toolbar.
To control the scene visibility from script, refer to SceneVisibilityManager.
场景可见性控件与场景拾取控件非常相似。
可以从 Hierarchy 窗口控制各个游戏对象在场景中的可见性。
要切换场景可见性,请执行以下操作:
切换对象及其子项的可见性会影响所有子对象(从“目标”对象一直到层级视图的底部)。
切换单个对象的可见性不会影响其子项。这些子项会保留以前具有的任何可见性状态。
提示:还可以单击场景可见性图标在隐藏和显示场景中标记为隐藏的项之间进行切换。
由于可以切换整个分支或单个游戏对象的可见性,因此最后游戏对象变为可见状态,但子项或父项为隐藏状态。为了帮助跟踪发生的情况,可见性图标会改变以指示每个游戏对象的状态。
A | 游戏对象可见,但是其某些子项被隐藏。 | |
B | 游戏对象被隐藏,但是其某些子项可见。 | |
C | 游戏对象及其子项可见。仅当鼠标悬停在游戏对象上时,才会显示此图标。 | |
D | 游戏对象及其子项被隐藏。 |
Scene visibility changes you make in the Hierarchy window are persistent. Unity re-applies them whenever you toggle scene visibility off and on again in the Scene view, close and re-open the Scene, and so on.
The Scene visibility switch in the Scene view View Options Overlay toolbar shows or hides GameObjects in the scene. Click it to toggle Scene visibility on and off.
关闭场景可见性本质上会使 Hierarchy 窗口中设置的场景可见性设置保持静默状态,但不会删除或更改这些设置。所有隐藏的游戏对象都是暂时可见。
重新开启场景可见性将会重新应用在 Hierarchy 窗口中设置的可见性设置。
Isolation 视图会暂时覆盖场景可见性设置,以便仅显示所选的游戏对象,而其他所有对象被隐藏。
要进入 Isolation 视图,请执行以下操作:
按下 Shift + H。
这样可隔离所有选定的游戏对象及其子项。隔离隐藏的游戏对象会使这些游戏对象可见,直到退出 Isolation 视图。
在 Isolation 视图中时,可以继续更改场景可见性设置,但是所做的任何更改都会在退出时丢失。
要退出 Isolation 视图,请执行以下操作:
再次按下 Shift + H,或者单击 Scene 视图中的 Exit 按钮。
退出 Isolation 视图将恢复原始的场景可见性设置。