Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

In-context Prefab Mode (preview build)

Discussion in 'Prefabs' started by Mads-Nyholm, Jun 13, 2019.

  1. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    Update: Prefab Mode in Context (the new name for in-context editing) will be in Unity 2020.1 and can be tested in alphas/betas of 2020.1 going forward.



    Recently we’ve been working on making it possible to edit a Prefab Asset in-context of the current scene or another Prefab. This is what we call In-context Prefab Mode (in addition to Isolation Prefab Mode as is possible today).

    So in short: Prefab Mode can now be opened in two ways
    • In-context
      • The Prefab Asset is opened from a Prefab instance through the Hierarchy. The Prefab Asset is shown in the context it was opened from, in place of the Prefab instance it was opened via.
    • Isolation
      • The Prefab Asset is opened through the Project Browser or through the Hierarchy using the Alt modifier key. The Prefab Asset is shown by itself, or using the environment scene specified in the Editor Settings.
    See the video below for an overview of the new feature:

    Video of In-context Prefab Mode

    We would appreciate if you took some time to try out the preview build below and give us feedback on the functionality and usability.

    Download preview build here (the preview build is based on 2019.3 a6)


    Additional information

    When opening in-context through a Prefab instance we make sure to adjust the appearance of the Prefab Asset to match that of the instance in the scene. We do that by temporarily patching up any properties on the content of the Prefab Asset to match the values of overridden properties on the Prefab instance. These temporarily patched up values are not saved into the Prefab. The patched up values ensure the Prefab Asset is positioned and scaled similar to the Prefab instance. All patched up values are non-editable in the Inspector in In-context Prefab Mode, so if for example the position of the Prefab Asset needs to be changed, then it typically needs to be done in Isolation Prefab Mode. Note that if any changes are made to these patched up properties by other means, such as moving objects in the Scene view, those specific changes won’t be saved.

    For the feedback build we have a toggle in the Preferences which can be used to alter which properties get patched up when editing Prefabs in context: All properties that are overridden on the instance, or only Transform/RectTransform properties that are overridden on the instance. When only Transform/RectTransform values are patched up, other properties that are overridden on the instance will appear with their original non-overridden values while editing the Prefab Asset. We’d like to know what works best for you.



    The approach of making the Prefab Asset match the appearance of the Prefab instance while editing it has a few limitations which means the appearance won’t always match completely.
    • Added components on the Prefab instance that alter the appearance of the Prefab (such as MeshFilter or ParticleSystem components) won’t be visible when opening the Prefab in-context. Note that this is specifically about components that have been added as overrides on the Prefab instance and don’t exist on the Prefab Asset. Added GameObjects will however still be visible.

    • For UI, the open Prefab will always render on top of UI elements in the context even if the instance is behind some of those elements normally.
    Also note that if entering Play Mode while editing a Prefab in context, the Prefab instance will be visible simultaneously with the patched up Prefab Asset, meaning it can appear as if there’s two copies of it.

    Note that you can setup shortcuts for entering Prefab Mode for both In-context and Isolation under the Stage category in Edit->Shortcuts...

     
    Last edited by a moderator: Oct 10, 2019
  2. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,105
    Coll stuff thanks :)

    One additional question :)
    Do you have in your roadmap note for Prefab Exposed Properties?
     
  3. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    It is on our own wish list but not on any roadmap currently
     
  4. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,105
  5. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,105
    May be something like read only prefabs, so no one can add overrides on prefab instance?
     
  6. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    Please use this thread for feedback on the new feature presented. Feel free to start a new thread with your questions.
     
  7. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    838
    Firstly thank you a lot for this, editing prefabs in this manner makes a lot more sense in my opinion. Its really a step in the right direction for the new prefab system!
    upload_2019-6-15_13-58-17.png
    Why is only one cone highlighted? They are all instances of the prefab right?
     
    Last edited: Jun 15, 2019
  8. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    You enter 'In-context Prefab Mode' via a specific instance so we only show the Prefab Asset at that location (and hide the instance). So the one highlighted cone is the the Prefab Asset you are seeing and the Hierarchy shows the full editable transform Hierarchy for this Prefab Asset. The others are still the instances in the scene.
     
  9. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,276
    Awesome! This looks great!
     
  10. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    517
    Would this work for Unity UI where a list item prefab need to know the context of the parent? Such as a list view that has the bounds or display context for the list item prefab?
     
  11. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    It should work. We have tested various UI setups, but there are a lot of edge cases.

    If you could download the build and try it out with your specific UI setups and see if works there, that would be very helpful.
     
  12. Doomlaser

    Doomlaser

    Joined:
    Dec 9, 2013
    Posts:
    24
    I would love for something like this to become the default way of editing prefabs. I haven't tried this build yet, but I hope something like this becomes part of Unity because the current workflow is far from ideal -- when in early stage creation of a prefab it is essential to see it in context of the scene, and that dialog in the current releases is a frustrating brick wall. Glad you guys are working on this.
     
  13. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    Just to make it clear, the dialog you refer to ("Cannot restructure Prefab instance") will still come up, but when you click "Open Prefab" you'll be able to edit the Prefab contents in context of the scene. The best way to get a feel for what it implies exactly is to try out the build. :)
     
  14. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    This is very important and useful for multiscene setups.
    Without context, it’s very hard for us to keep visual prefabs that live in different scenes in sync.
     
    Lars-Steenhoff likes this.
  15. ayellowpaper

    ayellowpaper

    Joined:
    Dec 8, 2013
    Posts:
    52
    Looks good. Are you also planning to add Isoliation Prefab Mode with multiple windows? So I can have multiple "Isolation Prefab Mode" windows open while also still being able to edit the scene. Would save a lot of clicks.