Search Unity

Feature highlight: Improved workflows for editing Prefabs in Unity 2020.1

, 11 августа, 2020

In Unity 2020.1, you can enter Prefab Mode without leaving the context of your scene. The new default means that when you open a Prefab Asset via an instance in the scene, you’ll be able to edit it with the background grayed out.

When we introduced Prefab Mode in Unity 2018.3, it became easy to edit a Prefab Asset in isolation. However, Prefab Mode has not been great for editing Prefab Assets in relation to the context the instances are in.

In 2020.1 we’re introducing an improvement to the Prefabs workflow that we call Prefab Mode in Context. Like always in Prefab Mode, you’re editing the Prefab Asset itself, not an instance, but the context is visible at the same time. 

When you open a Prefab for editing in Prefab Mode in Context, the context is grayed out by default, but you can easily switch it to be fully visible or fully hidden too. Just use the Context: control in the Prefab bar to set it to any of the following states:

  • Normal — Shows the context with its normal colors
  • Gray — Shows the context in grayscale
  • Hidden — Hides the context entirely so only the Prefab content is visible

When you open a Prefab for editing in Prefab Mode in Context, we actually hide the Prefab instance from the Scene, and show the Prefab Asset contents in its place instead. This is how we make the Prefab Asset appear in the same position as the Prefab instance.

Previewing overrides from the Prefab instance

You can see that the position and rotation properties of the root Transform are disabled for editing. This is because the position and rotation have been temporarily patched to get the same values as the instance has, so the Prefab Asset appears in the right position in the world. It wouldn’t make sense to edit the values, since it’s not the Prefab’s own values, but just temporary values used for the visualization. If you DO need to edit the position or rotation of the root Transform, you can do that when opening the Prefab in isolation.

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.

Properties that display overrides from the Prefab instance can’t be edited. The shown value is not the value the property actually has in the Prefab Asset — it’s just a temporary visualization. To be able to see and edit the Prefab’s own value for the property, you can turn off the Show Overrides toggle at any time.

Prefabs in Context for UI design

This new feature may be particularly useful for level design tasks and for UI (uGUI) work. It can be helpful for working with UI Prefabs because the parent RectTransform to the Prefab has the same size in Prefab Mode in Context as it does in the scene. This means that UI Prefabs keep the same size and appearance in Prefab Mode in Context as they have in the scene, helping designers have a better reference when they adjust the different elements that are part of that UI Prefab

Editing a child Prefab with the context of the parent UI window.

Let us know what you think

Please read Editing a Prefab in Prefab Mode documentation for more details, and go to Editor and Team workflows in Unity 2020.1 page to discover more improvements like this.

We hope Prefab Mode in Context will be a useful tool in your Prefab editing workflows. We’re looking forward to hearing from you on our Prefabs forum!

3 replies on “Feature highlight: Improved workflows for editing Prefabs in Unity 2020.1”

Still lots of things broken in the prefab/GameObject workflow:
* No way to mark things as «const» so that certain properties can’t be changed by the extending prefab or instance
* There’s not a good way to see and apply overrides, should be multi-select. And it’s sometimes hard to see what’s overriden in GO’s with lots of fields.
* uGUI shows up as overriden often. Also no way of layouts not affecting override status.
* No way to mark properties as «need to fill» so that the bug would be caught in build time, rather than run-time

Comments are closed.