Unity 2020.1 has a new improvement to the Prefab workflows called Prefab Mode in Context.
With Prefab Mode, you could always edit a Prefab in isolation. Now you can also open a Prefab in context. When you open Prefab Mode this way, you can see the context of the Prefab instance in the Scene view (but locked for editing) even though you are not editing the instance but rather the Prefab Asset itself (like always, in Prefab Mode).
You can try it out today in the Unity 2020.1 beta. Check out the documentation too.
Editing in Context
When you open Prefab Mode via a Prefab instance in the Hierarchy window, this opens Prefab Mode in Context. When you open Prefab Mode this way, you can see the context of the Prefab instance in the Scene view even though you are not editing the instance but rather the Prefab Asset itself. So if you for example open Prefab Mode in Context via a Prefab instance in a scene, then you can see the surroundings in that scene while editing the Prefab and the Prefab is shown with the same lighting conditions as in the scene.
A Prefab opened in Prefab Mode in Context, with the surrounding context displayed in gray scale.
(Pictured assets from the Asset Store package POLYGON - City pack)
If you have a Prefab instance that you do not want to open in context, but rather want to open in isolation, you can hold down the Alt key while clicking the Open button or the arrow button to open Prefab Mode. It’s also possible to setup a custom shortcut in the Shortcuts window for the command “Stage > Edit Prefab in Isolation”.
Controlling how the context is displayed
The visual representation of the context is by default shown in gray scale to visually distinguish it from the Prefab contents being edited. However, a control in the Prefab bar can be used to set it to any of the following states:
- Normal - the context is shown with its normal colors
- Gray - the context is shown in gray scale
- Hidden - the context is hidden entirely so only the Prefab content is visible
The Prefab Mode controls in the Prefab bar in at the top of the Scene view, including the Context control and the Show Overrides toggle
The objects that are part of the context are not selectable, nor will they show in the Hierarchy. This is to allow you to focus on editing your Prefab without accidentally selecting other unrelated objects, and without having a cluttered Hierarchy window. However, when you move objects around that are part of the Prefab contents, you can use the snapping features in Unity to snap to objects in the context, provided the context is not set to Hidden.
Previewing overrides from the Prefab instance
In Prefab Mode in Context, the Prefab contents are shown at a position that matches that of the Prefab instance it was opened through. This means the root Transform of the Prefab contents may be previewed with different position and rotation values than the Prefab Asset actually has. These values cannot be edited in Prefab Mode in Context. If you need to edit them, you can either open the Prefab in isolation, or you can select the Prefab Asset in the Project window and edit the values in the Inspector.
Apart from the root Transform properties, a Prefab instance can have other properties overridden as well, which may drastically change its appearance compared to the Prefab Asset it’s an instance of. You can preview these overridden values from the Prefab instance while in Prefab Mode in Context by enabling the “Show Overrides” toggle in the Prefab bar. While enabled, any properties that are overridden on the Prefab instance are previewed the same way on the Prefab contexts and cannot be edited. To be able to edit those properties, disable the “Show Overrides” toggle again.
Let us know how this is working for you!
Is the Prefab Mode in Context feature useful in your workflows? What do you use it for?
We think the feature may be useful particularly for level design tasks and for UI (uGUI) work but let us know what your own experience is.
Are you encountering any issues? Bugs or things that are confusing or unclear? Let us know!
The user manual page for the feature are not yet ready, but the above covers most of what it’s going to say about the feature. If anything needs to be explained better, let us know as well!