Search Unity

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:
    92


    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: Jun 13, 2019
    joshcamas and Lars-Steenhoff like this.
  2. Jes28

    Jes28

    Joined:
    Sep 3, 2012
    Posts:
    352
    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:
    92
    It is on our own wish list but not on any roadmap currently
     
  4. Jes28

    Jes28

    Joined:
    Sep 3, 2012
    Posts:
    352
  5. Jes28

    Jes28

    Joined:
    Sep 3, 2012
    Posts:
    352
    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:
    92
    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:
    403
    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:
    92
    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:
    707
    Awesome! This looks great!
     
  10. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    326
    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

    Unity Technologies

    Joined:
    Nov 28, 2007
    Posts:
    1,578
    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.