Search Unity

Improved Prefabs Introduction & FAQ

Discussion in 'Prefabs' started by LeonhardP, Dec 13, 2018.

Thread Status:
Not open for further replies.
  1. LeonhardP


    Unity Technologies

    Jul 4, 2016
    Hi everyone,
    Welcome to the discussion forum for the improved Prefabs features we're shipping in 2018.3. These features are:

    Previously, you were forced to choose between creating large monolithic Prefabs, like buildings, or more granular ones, like pieces of furniture, but you couldn't do both.

    Now with support for nested Prefabs, a large building can be made up of many smaller room Prefabs, which in turn can be made up of multiple pieces of furniture Prefabs, and so on.

    Prefab Variants
    As a default, a Prefab Variant inherits the objects and properties of the Prefab it is a variant of, but at the same time, you have the possibility both to override those properties and to add additional components and GameObjects. This is similar to the concept of inheritance in object-oriented programming.

    Prefab Mode
    A cornerstone of the new workflows, Prefab Mode enables you to edit Prefabs in isolation.

    Being able to edit an entire Prefab Asset without having to instantiate it in the scene or edit an existing instance means you can avoid mistakes related to accidentally applying overrides in the scene that shouldn't have been applied. Having editing of instances and asset as separate things lets you make your changes with confidence.

    You can find more detailed information about these features in the manual.
    For information about upgrading an existing project to 2018.3 please have a look at the upgrade guide.


    Here are some of the frequently asked questions.

    How do nested Prefabs and Prefab Variants impact performance?

    Performance at runtime: Prefabs are baked out as part of building players. Nested Prefabs, Variants, and even Prefab in general are not concepts that exist in built players. This means there is no CPU time spent on resolving nesting and applying overridden property values, since all content is “pre-nested” in the built process. It does mean that the data for GameObjects and components take up disk space and memory separately for each instance, since they exist as completely separate copies. This is all the same as in previous versions of Unity; no change there.

    Performance in the editor: Whenever a Prefab Asset is changed, it is re-imported, and all Prefabs that has it as a nested Prefab or base Prefab are imported as well. This means that the time it takes to save a Prefab after altering it scales with the number and sizes of other Prefabs that contain instances of it.

    Can we get back the ability to edit Prefabs directly in the Project Browser?
    This is supported in Unity 2019.1 and later. For 2018.4 please see this thread:

    Why is the root of a Prefab in Prefab Mode not blue and not using the Prefab icon?
    Prefab assets in the Project Browser and Prefab instances in the Hierarchy use the Prefab icon. Prefab instances use blue text too. In Prefab Mode, you are not seeing a Prefab instance, but rather the contents (such as regular GameObjects) that are inside a Prefab Asset. See the documentation for more information.

    Can we get the ability to be able to use Prefab Mode but edit the Prefab Asset in context of the current scene instead of in isolation?
    We are working on this functionality. Please see the preview build here:

    Can we have more convenient control over which environment scenes are used in Prefab Mode?
    We've had many requests to be able to specify environment scenes beyond what's currently in the Editor settings. Requests come in many different variations, such as:
    • Can we specify multiple environment scenes in the editor settings and be able to switch via drop-down in Scene view?
    • Can we set environment scenes per user instead of shared as part of the project?
    • Can we specify an environment scene per Prefab (stored in Prefab metadata)?
    • Can we drag environment scenes into the Scene view to switch on the fly?
    As you can see there's many different possible approaches to take. Solving it properly requires taking our time to iteratively design, test and validate a good solution. This won't be able to make it for the initial release but we’d love to look into it for a future release.

    Can we get the ability to simultaneously have a Scene view in Prefab Mode and one that shows the scene(s)?
    This is a common request and something that has been much on our minds. The functionality couldn’t make it for the initial release but we’d love to look into it for a future release.

    Can we get the ability to treat Prefabs as “black boxes” where specific properties can be set as exposed and only those can be edited at all on Prefab instances?
    This is something we’d like to explore for a future release. There are some non-trivial challenges involved, such as how to show individual properties in isolation when many properties currently rely on custom editors to be shown correctly.

    Can we get a tool to see which Prefab Variants inherit from a given Prefab, or even the entire inheritance graph?
    This is something we might explore in a future release. (It’s a bit related to being able to see asset dependencies in Unity in general, which there is also not any built-in tooling for.) For savvy users who want a solution in the shorter term, there is sufficient API exposed to be able to implement such tooling, in that you can see which base Prefab a given Prefab Variant inherits from.

    Can we get an indication that a Prefab instance has any overrides directly visible in the Hierarchy window or Inspector without having to open the Overrides drop-down and check?
    This is something we’d like to do for a future release. The main thing that kept us from doing it in the initial release is that it’s not so cheap to check this that we can do it constantly, and we don’t have a dirty tracking system in place for Prefab instances that we could use to cache the information and know when to invalidate the cache.

    Which callbacks related to Prefabs and Stages can I hook into from scripting?
    Additionally there are these in the experimental namespace
    Note that this is not guaranteed to work in future versions of Unity.
    Why do I get dialogs titled "Cannot restructure Prefab instance" / what happened with disconnecting Prefabs?
    Prior to Unity 2018.3 you could perform operations on a Prefab instance that would disconnect it from its Prefab Asset, such as deleting or reparenting GameObjects. Once disconnected, the Prefab instance would no longer receive updates from the Prefab Asset. Support for disconnecting Prefab instances has been discontinued in Unity 2018.3 because it's not compatible with the new Prefab features. Attempting to delete, reparent or reorder GameObjects in a Prefab instance will bring up a dialog saying it's not possible and suggesting making the edits to the Prefab Asset itself in Prefab mode, or unpacking the Prefab.

    Disconnecting Prefab instances is incompatible with new Prefab features such as nested Prefabs and Prefab Variants because disconnected Prefabs don't have a clear definition of what belongs and doesn't belong to the same Prefab instance. It's necessary to have clear definitions of that when also supporting nested Prefabs and Variants in order for all the logic that manages the various Prefab relationships to work.

    Replacement workflows are to either make edits to the Prefab Asset directly in Prefab Mode, or unpacking the Prefab instance (which makes it into regular GameObjects with no information about what Prefab they used to be part of). The root GameObject of what used to be the Prefab instance can be dragged onto the Prefab Asset to replace the Prefab, which is equivalent to how disconnected Prefabs could previously be reconnected again.
    Last edited by a moderator: Jul 10, 2019
    MihaPro_CarX, John3D and APSchmidt like this.
Thread Status:
Not open for further replies.