Search Unity

Nested Prefabs: Fully integrated, Completely automatic

Discussion in 'Assets and Asset Store' started by Visual-Design-Cafe, Mar 6, 2017.

  1. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721


    Fully integrated, completely automatic
    Nested Prefabs

    Get it now on the Asset Store!
    or
    Try Nested Prefabs for free!


    The most requested feature for Unity has finally arrived!

    Have you ever thought about how great it would be for your prefab connections to stay intact if you nest them? With Nested Prefabs for Unity this is now possible!


    Designed to be fully integrated and completely automatic, Nested Prefabs perfectly blends in with your workflow. Use the regular Unity prefabs and inspector and be amazed by how your prefab connections stay intact. No need to change your workflow, no additional editor windows, no hassle. It just works.


    Key features

    • Fully integrated, completely automatic
    • Works with regular Apply button/Unity prefab system
    • Keeps object/script references intact
    • Can handle custom serialized classes
    • Supports prefab override properties
    • Apply modifications to a Nested Prefab without applying changes to its parent

    With Nested Prefabs for Unity you can simply create prefabs how you normally would. If you nest a prefab and apply the changes, the connection to the original prefab is maintained. Making any changes to the original prefab and clicking (the regular Unity) Apply button will automatically update all Nested Prefabs with your changes. Making any changes to a Nested Prefab and clicking Apply will also update all other Nested Prefabs and the original asset.


    A visual explanation of Nested Prefabs


    The Nested Prefabs are visible in the hierarchy to make it easy to keep track of them, and to show which prefab/object you are editing:


    If you need to apply changes to a single nested prefab you can right-click on the icon and choose an option from the menu:​


    All serialized properties in Unity are supported, even the most complex custom classes:


    To make sure Nested Prefabs is stable, and stays that way there are over 200 unit tests to test every single feature:
     
    Last edited: Sep 6, 2017
  2. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Do you have a preview version I can try? :)
    What will the price be?
     
    Last edited: Mar 6, 2017
  3. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @dadude123
    There is no official preview version, however if you send me an email at max@visualdesigncafe.com I'll make sure a preview build is made and sent to you as soon as possible so you can try it out.
    The price for the first version at release will be $30.
     
  4. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    email sent :)
     
  5. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @dadude123
    Thanks, I have sent you a preview build!

    For Everyone:
    If anyone is interested in a preview build to try out Nested Prefabs, please feel free to contact me by PM or email.

    If you want to be notified when Nested Prefabs is available on the Asset Store you can subscribe to this thread!
     
  6. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Just got around to testing it and I have a question.

    Can I save changes on just the parent prefab, not saving changes in the children?
    I have a window and a button (both prefabs) and I make some changes to the button (specific to the window).
    When I hit apply on the window, it also applies all changes that have been made to the button.

    A simple "Apply - (Only this object)" button would be great.

    The situation is quire common. A window + two buttons, one button is the default (unchanged prefab) and the other is tinted a bit (lets say a cancel button that is a little red).
    Now when I apply changes to the window I don't want all buttons to become tinted red.

    Is there anything that can be done about this?
    It doesn't have to be super-granular control like being able to say "only apply those properties", that'd likely become way to complex. But being able to at least only apply to certain "layers" would be really helpful.
     
  7. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @dadude123
    You have a good point there. Unfortunately it is not possible at the moment, though I agree with you that it is definitely necessary. I will make sure to add this feature to the task list for the next update with a high priority. The internal algorithm already supports this behavior for the most part so it should be possible to add it rather quickly. You can expect it a few days after release (up to 1 week or so, depending on the review time of the asset store team)
     
  8. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Cool,
    there are actually a few more edge cases that I'm curious about.
    People have tried this nested prefab stuff before and every solution had some major problems, but your's seems to be pretty solid so far.

    I'll report back with more information later :)
     
  9. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Found a bug.
    When all the properties get transfered to the "other" prefabs, the values in RectTransform are not transfered/updated correctly.

    How to reproduce:
    You have two prefabs, PrefabA contains PrefabB (so B is the child).
    Place two instances of A in the scene, add an Image (normal Unity image) as child of B (so now its a->b->c).
    Hit apply on C. Other B-Instances inside your current A will be updated immediately, the others get their values updated with a small delay (I guess thats "NestedPrefabs" doing its thing, right?).

    Now in the other A-instance the images are there, but the transform settings are wrong.
    If you change anything and hit apply again, the settings are transferred correctly (size, anchors, pivot, ...).
    So it only happens on the first time.


    edit:
    Other than what I noted above it seems pretty solid (so far :))
    Tomorrow I'll do more in-depth testing with instantiating prefabs from code (just at runtime for now).
    Seeing if basic links between stuff is handled correctly...

    Like it is right now I'd give it 4.5 / 5. With some more development this could become a must-have.
    Let's hope it scales well when you have a larger project.
     
    Last edited: Mar 7, 2017
  10. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @dadude123

    Thank you for the in-depth testing and detailed report, it is appreciated a lot!
    So far I am not able to reproduce the issue you mentioned with the RectTransform, but I'll continue trying.
    Which version of Unity are you using to test? The first time a component is copied into a Nested Prefab the default Unity copy method is used, it might be an internal Unity issue with the UI system. The second time you click apply the custom Nested Prefab serializer and diff check will apply your changes, instead of Unity.
     
  11. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    I'm using 5.5.0f3.
    It seems then that Unitys copy function is buggy.
    At the moment I can't reproduce it anymore because unity crashes instead when I click apply haha.
    I submitted a bug report to unity for that.

    I'm trying to reproduce it in a new project now and when that works I'll upload it h ere.

    edit: sent you a pm
     
    Last edited: Mar 7, 2017
  12. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @dadude123
    Thanks. I have sent you an answer in PM regarding your questions as well.

    Regarding the crash, I had the same crash when trying the project you sent. However, after recreating the exact same prefabs in your project (and another project) it did not crash. I will look into this issue to see what in Unity causes this exactly and if there is a workaround.
     
  13. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    For anyone who is interested in this extension, here are two animated gifs to show the process of creating and editing a nested prefab.
    If the Unity Asset Store team is on schedule then Nested Prefabs for Unity should be available this week!

    Creating new nested prefabs:


    And editing one:
     
    tapawafo and dadude123 like this.
  14. tapawafo

    tapawafo

    Joined:
    Jul 25, 2016
    Posts:
    170
    Can't wait until this is on the asset store! Looks fantastic. Would be a lifesaver for me as it would vastly simplify the workflow for procedural generation in my project.
     
    Visual-Design-Cafe likes this.
  15. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    There has been a small delay in the submission process due to the Visual Design Cafe website homepage being under construction at the moment. Luckily this issue has been resolved quickly and according to the Asset Store Team the asset should be available in 1-2 business days!

    As a positive side note to this delay; it was possible to include the latest update of the extension, therefore there will be more features available at launch!
     
    dadude123 and tapawafo like this.
  16. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Nested Prefabs has been released! You can see it on the Asset Store here!
     
    TeagansDad and tapawafo like this.
  17. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Nested Prefabs version 1.1.2 has been submitted to the Asset Store!
    Hopefully it will be reviewed and accepted quickly.

    The following changes have been made in this new version:
    • Added support for multiple components of the same type.
    • Fixed a NullReferenceException when there is a missing script in a prefab.
    • Fixed nested prefab icon color when the changes are not yet applied to the parent prefab.
    • Improved internal error handling.
    • If Unity by some chance changes the GUID of the NestedPrefabs.dll file, the GUID will now revert automatically to prevent missing script references.
    • Fixed issue where relative object reference would be incorrect.
    • Float and Vector values of Infinity are now applied correctly.
    • Fixed issue where certain complex serialized propreties would always be copied entirely, even if nothing changed.
    • Improved performance when applying changes to a nested prefab with the regular Unity Apply button.
    The full changelog can be found here.

    Please feel free to post a message here if you have any feedback or ideas for future versions of Nested Prefabs!
     
    tapawafo likes this.
  18. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    There is now also an official trial version available for Nested Prefabs. The trial includes all features but is limited to 10 unique prefabs. (You can nest 1 prefab as many times as you want, but you can not have more than 10 different prefabs).

    The trial can be downloaded here.
     
  19. darky12s

    darky12s

    Joined:
    Dec 7, 2015
    Posts:
    1
    Bought it today. It's quite cool. But there's a huge problem I'm facing :
    Is there any way to create a prefab composed with a set of nested prefabs without "applying" modifications to the nested prefabs ?

    Because I have a "button" prefab with some default properties that are used in many places with custom props. But whenever I create a prefab that use buttons, it resets the custom props of all buttons instances. Which makes the plugin kinda unusable.
     
  20. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @darky12s
    Unfortunately that is not possible at the moment. When you add a new object it is required to apply the entire prefab since Unity does not allow to have any prefab with a modified hierarchy compared to the original prefab.

    A new feature is planned for the next major update to allow for permanent override properties that can be saved for each prefab, once that feature is added it should be possible to do what you are describing. Until then I am afraid you will have to modify those properties for each instance in the scene to keep the prefab overrides.
     
  21. tapawafo

    tapawafo

    Joined:
    Jul 25, 2016
    Posts:
    170
    I've been using Nested Prefabs for a few days now and it's great! Very easy to work with.

    However, I'm having a strange issue.

    I have a player root prefab, and in that prefab I have some nested prefabs for the head, torso, and limbs. I created these prefabs one at a time, applying to the prefab as per usual, and have had no issues until today.

    When I made a change to the 'M8HeadObj' prefab, and also added a mesh object ('head' in the picture'), I can now no longer apply changes to any of the prefabs - they all display a red X and I get no errors or feedback in console.

    Image: (snipped because issue was solved below)

    When I right click > apply on the root prefab, nothing appears to happen. When I right click on the red-x nested prefabs, the only option is to break prefab connection.

    Is this behavior familiar to you? If so, how should I resolve it?

    Thanks.
     
    Last edited: Apr 12, 2017
  22. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @matteumayo
    The red x means the (root) prefab is disconnected by Unity. The Nested Prefabs extension will prevent you from editing disconnected prefabs (locally, through the icon menu) to make sure the prefab does not get corrupted (Unity doesn't handle changes to a disconnected prefab well). The easiest way to fix this is by clicking the Apply button in the Inspector to apply all changes and reconnect the prefab, or by clicking Revert in the Inspector.

    Note: If you are using Unity 5.6 and Unity gives an error message when applying/reverting or Unity disconnects the prefab immediately then please check if there are any missing scripts on your prefab. There is a bug in Unity 5.6 that messes up the prefabs internally when there is a missing script (it has nothing to do with the extension).
     
  23. tapawafo

    tapawafo

    Joined:
    Jul 25, 2016
    Posts:
    170
    @Visual-Design-Cafe
    Thanks for the quick response!

    I am on 5.6.0f3 and it was in fact a rogue missing script on an object deep in the hierarchy. Everything's working. Thanks! :)
     
    Visual-Design-Cafe likes this.
  24. tapawafo

    tapawafo

    Joined:
    Jul 25, 2016
    Posts:
    170
    Hello again,

    Is there any special procedure to follow when updating NestedPrefabs (the asset) to a new version? Is it the standard procedure of deleting the old version and installing the new?

    I ask because I know NestedPrefabs must be installed after importing it into the project, so I want to make sure I don't screw everything up. :)

    Thanks.
     
  25. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @matteumayo It is best to simply import the new package while the old version is still in the project. Unity should automatically overwrite the old plugin with the new file. It only has to be installed the first time you use the plugin in a project.
     
    tapawafo likes this.
  26. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @Visual-Design-Cafe ,

    Hi - thinking about buying this when in sale. Will it work and play well with Playmaker (thinking of FSMs within child prefabs etc)?
     
  27. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @Duffer123,
    Nested Prefabs supports all kinds of custom serialized classes and types so it should work fine with Playmaker, although it has not been specifically tested with it. If you want to be sure you can test it with the trial version: https://www.visualdesigncafe.com/products/nestedprefabs/trial/
    Please let me know if the trial does not work well with Playmaker and I'll make sure to add support for Playmaker specifically.
     
  28. tapawafo

    tapawafo

    Joined:
    Jul 25, 2016
    Posts:
    170
    Hello,

    I am constantly getting strange errors when playtesting a scene with a few nested prefabs in editor. The errors do not seem to occur on a fresh restart of Unity, or at least without messing with any objects in the scene before hitting play.

    The errors during play mode seemed at first to occur randomly, but I think they're happening any time anything in a prefab in the scene is changed.

    The errors occur in pairs, first,

    Failed to create Nested Prefab
    (pastebin of full log https://pastebin.com/YyLqLcsH )

    and then,

    Assertion failed on expression: '!m_isUndoing'
    (pastebin of full log https://pastebin.com/0HwDfQqy )


    When I said above that the errors occur when something is changed, I mean if it's done via script, or even if I change a value while in playmode - it undoes the value I changed, and throws that error.

    Thanks in advance for any help.
     
  29. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @matteumayo

    I have looked into the issue and there is still a postprocessor running during playmode, which shouldn't happen. The postprocessor checks the nested prefabs in the scene if they are valid and detects changes. In playmode all nested prefabs are removed/disabled so it runs into an error since it can't find the prefab. I have fixed it and will publish an update as soon as possible.
    My apologies for the inconvenience this is causing.
     
    tapawafo likes this.
  30. tapawafo

    tapawafo

    Joined:
    Jul 25, 2016
    Posts:
    170
    @Visual-Design-Cafe

    Fantastic! I was worried it would be something more serious. Glad to hear you found the solution. :)

    Thanks.
     
  31. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Important notice for everyone using Unity 5.6:
    In Unity 5.6 the Apply button is enabled for prefabs in play mode, this is a new feature of Unity and unfortunately it does NOT work with Nested Prefabs! Applying changes while in play mode will break your nested prefab connections. Unity itself also throws an exception when applying changes during play mode.
    I'll look into this new feature and see if supporting an Apply button in play mode is something that can be done in the near future.

    @matteumayo
    The new version (1.1.3) has been submitted to the Asset Store, it should be available soon (usually 1-2 days for updates, but it really depends on the Asset Store Team). If this issue is hindering you with your work and you need the update sooner then please send me a pm with your email address and I'll send you the update directly.
     
    tapawafo likes this.
  32. AndreBengtsson

    AndreBengtsson

    Joined:
    May 6, 2016
    Posts:
    14
    Hi there!

    Great to be able to use nested prefabs :D

    However, we have run into a problem we suspect has something to do with Nested Prefabs. Randomly when we save the scene, Unity freezes for a a couple of minutes before starting to import small assets. This can happen at any time, even after just adding a line of code to a scrip not connected to anything, and then saving. It doesn't happen every time, which is weird. It's really tough to work with, as it happens quite often.

    Would be great if you had any idea what this could be.

    Thanks in advance!
     
  33. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @AndreBengtsson

    Thanks for using Nested Prefabs!
    Whenever you save a scene Unity will also save all modified prefabs. When Unity saves a prefab, the Nested Prefabs extension will apply these modifications to any nested prefab as well. The 'Importing small assets' message here is the prefabs that are being reimported/saved.

    This should normally only happen if you have modified a prefab, however it is possible that a script automatically modifies a prefab after it is imported. If this happens the prefab will always be reimported every time you save the scene, if a lot of prefabs are modified like this it will mean every prefab in your project will be reimported.

    Please check which prefabs are being imported when you save the scene, the only prefabs that should be imported are any prefabs you have modified and the parent(s) of those prefabs if they are nested somewhere.
    You can check which prefabs are being imported with this script:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using System.Text;
    4. using UnityEngine;
    5. using UnityEditor;
    6.  
    7. public class PrefabImportLog : AssetPostprocessor
    8. {
    9.     public static void OnPostprocessAllAssets( string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths )
    10.     {
    11.         var importedPrefabs = new StringBuilder();
    12.  
    13.         foreach( string path in importedAssets )
    14.         {
    15.             if( !path.EndsWith( ".prefab", System.StringComparison.OrdinalIgnoreCase ) )
    16.                 continue;
    17.  
    18.             importedPrefabs.Append( "Imported: " );
    19.             importedPrefabs.AppendLine( path );
    20.         }
    21.  
    22.         foreach( string path in deletedAssets )
    23.         {
    24.             if( !path.EndsWith( ".prefab", System.StringComparison.OrdinalIgnoreCase ) )
    25.                 continue;
    26.  
    27.             importedPrefabs.Append( "Deleted: " );
    28.             importedPrefabs.AppendLine( path );
    29.         }
    30.  
    31.         foreach( string path in movedAssets )
    32.         {
    33.             if( !path.EndsWith( ".prefab", System.StringComparison.OrdinalIgnoreCase ) )
    34.                 continue;
    35.  
    36.             importedPrefabs.Append( "Moved: " );
    37.             importedPrefabs.AppendLine( path );
    38.         }
    39.  
    40.         Debug.Log( importedPrefabs.ToString() );
    41.     }
    42. }
    43.  
     
  34. AndreBengtsson

    AndreBengtsson

    Joined:
    May 6, 2016
    Posts:
    14
    Thanks for the info :)
     
  35. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    429
    Your plugin looks great, just wanted to wish you luck and success in development in maintaining.
    Maybe some day I will buy it because unity does not seem to want to create their own solution.
     
  36. IAmJustADog

    IAmJustADog

    Joined:
    Aug 9, 2013
    Posts:
    8
    @Visual-Design-Cafe
    Hi, I have found an annoying bug:

    To Reproduce:

    Create two prefabs. At least one prefab should have a child.
    pic1.PNG
    Duplicate the child and try to drag it into the other prefab. It also doesnt work if you drag it first out and then into the secound prefab. Importand: There must be two different prefabs.
    It only works if the prefabs are the same.
    Error Message:
    Code (CSharp):
    1. Failed to create Nested Prefab
    2. UnityEngine.Debug:LogError(Object)
    3. VisualDesignCafe.Editor.Prefabs.NestedPrefabPostprocessor:RefreshObjectsInSelection(GameObject[])
    4. VisualDesignCafe.Editor.Prefabs.NestedPrefabPostprocessor:OnHierarchyWindowChanged()
    5. UnityEditor.EditorApplication:Internal_CallHierarchyWindowHasChanged()
    Through this bug, it is impossible to clone gameobjects from prefabs and to plug into other prefabs.

    I hope you find the bug soon!


    And if there is time ... how far is the progress with the feature of @darky12s post #19/#20?
     
    Last edited: Apr 29, 2017
  37. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @Heia-Samahi,

    Thanks for reporting this bug. I can confirm that it is indeed broken in the current version. Luckily it has already been fixed in the next update (1.1.4), it should be available sometime this week.

    The feature is currently in an experimental state. It seems to be working well and will be send out as a beta version soon (this week or next week). If you are interested in testing the beta version then please feel free to send me a PM and I'll send you the beta version once it is ready.

    Here is a screenshot of what the feature currently looks like:
    prefaboverrides.jpg
     
    IAmJustADog and laurentlavigne like this.
  38. MaddoScientisto

    MaddoScientisto

    Joined:
    Jan 30, 2015
    Posts:
    62
    I just had an unity crash while using this, it's also a pretty consistent crash.
    I moved a script under a different namespace but that script was used on a bunch of objects inside nested prefabs, the whole hierarchy became "broken" (They have a a red X), so I started changing the scripts of all the affected objects but still the x wouldn't go away.

    eventually I figured out that there was a single object still missing the script so I changed it and tried to apply the prefab... and then crash.

    I attached the crash log, hoping it helps, if you want to try the project I can give you private access to the repository.

    Deleting the affected object seems to have prevented the crash and fixed the prefab.
     

    Attached Files:

  39. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @MaddoScientisto

    Unfortunately this issue is caused by Unity itself. In Unity 5.6 if there is a missing script in a prefab Unity will disconnect all prefab instances, reverting any changes to the prefab will cause a NullReferenceException as well. (The red X means the prefab is disconnected)

    The crash should never happen though. I have tried to reproduce this but I can't seem to get any crash. Breaking the prefab like this, restoring scripts and applying the changes works fine here. It would be great if you could give me access to the repository, the prefab must be broken in a very specific way.
     
  40. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    In this case how do I apply parenting a prefab to a child prefab at the root level without changing the child prefab by pressing apply (the default behavior which I kept using thinking it'd apply changes to the root only)
     

    Attached Files:

  41. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @laurentlavigne
    Unfortunately it is not possible to apply a new child without applying the entire prefab. The default Unity prefab system has a limitation that the hierarchy can't differ from the original prefab, so adding, removing or reparenting children should always be applied to the entire prefab.

    In version 1.2.0 you don't have to worry about this anymore though, as it introduces the permanent Prefab Overrides feature. With this feature you can save overrides inside a prefab and they will stay overridden even if you apply the changes. So you can simply add your overrides to the prefab and apply the entire hierarchy when adding a child without having to worry about applying the overridden properties.
    You can expect this feature in 1-2 weeks (beta version should be available this week if you are interested).
     
  42. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    Ok I thought you were overriding the editor button.
    How do you push an apply prefab to the sub prefabs when Apply is pressed?
    And I thought I saw a contextual menu that allows to Apply to root only, maybe that's the override you're talking about now.
     
  43. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @laurentlavigne

    - Using apply in the inspector will apply the entire hierarchy of the object at once.
    - Right-clicking on the prefab icon and choosing Apply will apply the prefab and all its nested children
    - Right-clicking on the prefab icon and choosing Apply Self will apply only the prefab itself, not applying changes to any children or parents.
     
  44. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    Gotcha, I didn't get that the icon itself was a hotbox.
     
  45. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Hi everyone, here is an important notice about the current state of the plugin and plans for the near future.

    TL;DR Unity shows warnings in a build because the nested prefab data is editor-only and is not included in a build. This has a big impact on performance. A solution has been made and is being tested, it will be released as soon as possible.

    Right now there is one major issue with the plugin, the additional data stored in prefabs to keep the nested prefab connections is currently stored on components. These components are not included in a build, since they are inside an editor-only plugin. Unfortunately Unity still serializes this additional data. This means that Unity will try to load the data in a build, because the components itself are not included Unity will log a warning message, similar to this:

    All these warning messages have a huge performance impact, which means that (ironically) not including the components costs more performance than including them.

    My sincere apologies for not having tested this more thoroughly in a build while developing the extension.

    This issues has raised quite a few questions and is currently being addressed with the highest priority.
    A fix has already been made and is being tested, it will be released as soon as possible.

    The fix consists of two parts:

    1. All components will be separated into a different plugin, which will be included in the build. Doing this will prevent the warning messages and the components will destroy themselves as soon as they are loaded to not interfere with your game.

    2. An API is made available to import/export/remove the entire prefab database with all components and data from your project. This will allow you to temporarily uninstall Nested Prefabs so you can build with a clean project, not containing any nested prefab data (zero overhead in your project). After building, all data and nested prefab connections can be restored.

    - For regular builds there are menu options available to export and remove the prefab database before a build and import it again afterwards. Or the API can be used if you have a custom build process, it only requires 2 method calls; one before and one after building.
    - For those using Unity Cloud Build there is an API available to automatically take care of this.
    - For those using Unity 5.6; there are build preprocessors and postprocessors available to hook into the Unity build pipeline and also take care of this automatically.

    More details about the API along with documentation and examples is being worked on to be released along with the update.

    If you have any questions regarding this issue and/or specifics for your project please feel free to either post here, send a PM or an email.
     
    Brogan89 and tapawafo like this.
  46. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    Would be nice if you slipped into that change nested asset ;)

    If I understand, you are switching from editor-only on-prefab script that contains all the GUIDs to runtime + editor on-prefab script that calls a database. Why would you need to store any data in the new component? Seems that at editor time you can read this.GUID, look that up as key in the database via resource.load and get a list of sub prefabs and their parents in the database as well - no?

    Not an important distinction if
    means a one time decimation cost at app load, well even if it means instantiation, I pool everything so no cost so very little cost.
     
  47. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Not exactly. Actually, nothing changes for the behavior. All components and the extension still work exactly the same, however the components are now included in a build to prevent warnings by Unity. The components in a build don't do anything at all, besides destroying themselves at startup. The only purpose of including them is to prevent warnings by Unity.

    Besides from this change there is a new separate system to export/import all components into a single database that is stored on disk. When you make a build, all components are removed from the prefabs and stored in a temporary database outside of your project. Then you can build your project without any components included. After building you can import the external database again and it will restore your components. This database system does not have any influence on how the extension works internally, it is simply an export/import method.
     
  48. sboxle

    sboxle

    Joined:
    Sep 27, 2014
    Posts:
    8
    Hi, your plugin's made my workflow a lot easier, but there's an issue I've been banging my head against. I think I've finally figured out what's going on and it seems like it might be a bug.

    So I'm working with a nested prefab like this:

    • NPC prefab (enabled/visible)
      • Coin Reward prefab (disabled/invisible)
        • Particle FX prefab (enabled/visible)

    I've had a bunch of issues with the Coin Reward prefab not staying disabled. But I've just realised that when I apply the Particle FX prefab (child) while it's enabled, it enables the Coin Reward prefab (its parent) as well.

    Is that a bug? The prefabs are set up like this across multiple NPC prefabs.

    To fix this manually I had to go into the Unity's project file explorer and disable the Coin Reward layer on each, before replicating that in scene and hitting apply.
    If I just turned Coin Reward prefab off in the scene and hit apply it'd turn the Coin Reward back on in scene, and if I just turned Coin Reward off in project explorer it didn't update the scene ones (Unity freezes on save) and it'd turn back on in project explorer when applied in scene. I had to do both. In general there's been a lot of freezing with this conflict.

    Otherwise had no big issues with Nested Prefabs so far!
     
  49. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I have used some nested prefab solutions and I am unfortunately like many others, burnt with it so bad that I lost hope with it.

    This one seems interesting, but how does it perform when you deal with large projects with a lots of nested prefabs? if I have like 1000 prefabs (a) that has another prefab (b) and modify prefab b and apply how does it perform? The previous nested prefab solution brought the editor to its knee taking around 10 mins to apply it. It also scanned the entire projects for nested prefab changes etc.. which also took 10s of mins. I eventually wanted to remove the system, but it didn't even have that option.. so I deleted the asset from the project but that left with 1000s of missing scripts etc.. it just goes on!

    How does this one differ? If I may ask boldly! :D
     
    Peter77 and laurentlavigne like this.
  50. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    I just checked it for you. It is not a bug, currently the IsActive state of the game object is loaded from the original prefab. However it is quite confusing and doesn't make a lot of sense for any workflow, therefore I have marked that property to not be loaded from the original prefab from now on. I have included this change in the 1.2.0 update which should be available soon. Please send me a PM if you require this version before it is released on the store and I'll send it to you directly.
     
    sboxle likes this.