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
    @castor76
    Thank you for your interest in Nested Prefabs. I am happy to say my nested prefabs solution is faster than all other solutions out there!

    If all 1000 prefabs have the same prefab then it will take a while to apply changes, since all 1000 prefabs have to be modified. The biggest performance hit here is that Unity has to save all 1000 prefabs to disk. Having 1000 prefabs which all reference different prefabs will be no problem at all.

    I have done a little performance test for you. In this test the changes will be applied to a simple dialog box prefab. The prefab contains 4 nested prefabs, of which 1 has a prefab override property saved in it (the text of the cancel button is overridden from 'Ok' to 'Cancel').

    In the test the position of the Background object will be changed and applied using the regular Unity apply button.
    Using the regular Apply button means all prefabs in the entire prefab hierarchy will be applied, so in this case all 4 nested prefabs and the root prefab will be applied (5 prefabs in total).


    These are the results when in an empty scene with only a single prefab (the one above). The project has either 1 prefab asset, 100 prefab assets or 1000 prefab assets in it. These assets are random prefabs that do not reference the dialog box above.

    The blue bar is an example when there are 100 copies of the asset above in the project, all referencing the same original prefab. (The situation you described). Note that the blue bar is missing for '1 Asset', since having 100 copies means there is already more than 1 asset in the project. It is also missing for 1000 assets since there is a safety system that stops the internal apply loop if there are more than 100 prefabs referenced by the same prefab. (It is not a technical limitation, just a safety measure and can be disabled if required)

    The results are in milliseconds and only includes the apply time, the actual saving of the prefabs to disk is not included as I have no control over the save/import time of Unity. (the save time is just Unity importing the modified prefab, similarly as importing a completely new prefab)


    And here is the same test but with 100 copies of the same prefab in the scene:


    If you want to test the speed yourself you can try it out with the trial version:
    https://www.visualdesigncafe.com/products/nestedprefabs/trial/

    Edit:
    There is an 'Uninstall' button in this one ;)
     
    Peter77 and tapawafo like this.
  2. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Very tempting.. what is the restriction with trial version? can i test 1000 referenced prefabs using the trial?
     
  3. sboxle

    sboxle

    Joined:
    Sep 27, 2014
    Posts:
    8
    Thanks for looking into it!
    I can't seem to PM you... Unity forum not cooperating at the moment... Will try again later. Looks like I might just be waiting for 1.2 haha
     
  4. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @castor76
    The trial is limited to 10 unique nested prefabs. So if you have 1 nested prefab and copy the parent prefab 1000 times it should work fine, as it still counts only 1 unique nested prefab. You just can't reference more than 10 different prefabs.
     
  5. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @sboxle
    I have sent you a PM with a download link for 1.2.0.
     
  6. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    I am happy to announce that version 1.2.0 is now available on the Asset Store!

    This new version comes with two major features: Prefab Overrides and a Build Processor.

    Prefab Overrides
    With this feature you can now save property overrides in a nested prefab. When you click apply this property will stay overridden and it will not be applied to the original prefab. A short explanation of this feature can be found in the online documentation.

    @darky12s, please take a look at the feature above, you requested this one as well a while ago :)

    Build Processor
    As of this version, components are no longer included in a build to fix the performance issues that occurred in previous versions. It requires a few extra steps when making a build: a guide on how to make a build can be found here.

    If you decide to make a build without the additional steps described in the guide the components will still be included, however the overhead has been drastically reduced and shouldn't be as noticeable as before.
     
  7. igor84

    igor84

    Joined:
    Oct 30, 2015
    Posts:
    7
    Hi,

    I am testing your plugin with our custom gui library which is based on NGUI. There are some things that we need and I am not sure if and how I can accomplish with your nested prefabs.

    We need a way to say that some properties on some of our components are always instance specific, which means no matter how their value is changed that change should never be saved into a prefab file or even mark that prefab as changed.

    If I understood correctly your PrefabOverrides allows to specify this on concrete component instances but how could I get it on all instances by default for some properties?

    Also I can't add PrefabOverrides to non-nested prefab so if I just create a prefab and won't to say that some of its properties should never be saved in a prefab file I can't do that either, right?
     
  8. sboxle

    sboxle

    Joined:
    Sep 27, 2014
    Posts:
    8
    Updated to 1.2.0.

    Just wanted to check one more thing - whenever I save the scene it changes all the prefabs in the scene (this has happened for awhile, not a 1.2.0 thing).

    Is that intended behaviour or is something in our setup conflicting?
     
  9. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @igor84,
    Currently there is no easy way of doing this. If the components you are using are fairly simple you can add a CustomProcessor with a list of the properties you want to include:

    Code (CSharp):
    1. [CustomProcessor( typeof( YourClass ) )]
    2.     internal class MyCustomProcessor
    3.     {
    4.         public string[] Properties
    5.         {
    6.             get
    7.             {
    8.                 return new string[]
    9.                 {
    10.                     "property 1",
    11.                     "property 2",
    12.                     "property 3",
    13.                     "etc.",
    14.                 };
    15.             }
    16.         }
    In the next update I have added a DontSaveInPrefab attribute which you can add to a component (not a property). So if your setup allows it you can move the properties you don't want to save to a separate component with the DontSaveInPrefab attribute.

    However both of these options only work for nested prefabs. If you don't nest a prefab the regular Unity prefab system is used, and Unity will always apply the values to the prefab.

    @sboxle
    If you mean all prefabs are reimported you might have the same issue as explained here:
    https://forum.unity3d.com/threads/n...ted-completely-automatic.459495/#post-3048407
     
  10. PinkTsunami

    PinkTsunami

    Joined:
    Dec 8, 2014
    Posts:
    3
    How do i handle "Nested Prefab depth limit reached" error? It's ignorable?
     
  11. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @PinkTsunami
    The error means you have reached the maximum number of nested prefab references. Any prefab over the maximum number will not be updated with your changes so it shouldn't be ignored.

    The maximum number is only a safety check and not a technical limitation, so it can be increased without any problem. I just checked and I see that the release version is still using a number of 21, which is a legacy number from a previous version. It has already been increased to 1000 in the latest development version. If you need a build with this number increased then please send me a PM and I'll send you a new custom build.
     
    PinkTsunami likes this.
  12. sboxle

    sboxle

    Joined:
    Sep 27, 2014
    Posts:
    8
    I'm not sure what's going on, but since the update I've had to deal with it updating all prefabs in the project multiple times. Is that the same issue as the issue you'd linked to last post?

    I work with one other person and looking at SVN change lists it seems to be changing the fileID for every prefab either when I save or open the project (I'm not exactly sure when it's occuring), including obsolete prefabs with no dependencies.

    And all these prefabs with changed fileID's haven't been overwritten by version control between changing. I checked all the updated ones in yesterday and today they've all changed again.

    I did notice in the .meta files it changes LicenseType between free and pro as only one of us has a Pro license at present. That was an isolated .meta file that changed though, so a bit of an aside. All the prefabs changing fileID don't have changed .meta files.
     
  13. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @sboxle,
    I have checked it for you and it is mostly likely caused by the automatic processor that runs when making a build. The processor removes all internal components from the prefabs in your project before a build and restores them again after. Removing and adding the components will give the component a new ID and mark the prefab as changed, therefore they will need to be reimported and they will be marked as Modified in SVN.

    If you do not require the build to be processed you can disable the 'NestedPrefabsBuildProcessor' script in the 'Nested Prefabs/Editor' folder. Just commenting out all code should do it. Not processing the build means the internal components will be included for assets instanced at runtime, which has a small overhead.

    For more information about the build process please check the guide here
     
    sboxle likes this.
  14. sboxle

    sboxle

    Joined:
    Sep 27, 2014
    Posts:
    8
    Oh right! Great thanks for that info. Yea I had done multiple builds, I didn't connect the two. Good to know!
     
  15. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    nested prefab english anyone.PNG
    Too many words, this need to be simplified.
    Here is the scenario:
    there is a nested asset in a prefab
    I'm changing the prefab's hierarchy or adding a component to the root, not touching the nested asset
    RMB > apply self
     
  16. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    bug: when applying to self, all references to objects in the scene disappear from the prefab instance.
     
  17. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @laurentlavigne
    I am thinking of a way to explain that warning better.
    It basically means it is not possible to apply any changes locally if the hierarchy is modified, not matter where in the prefab hierarchy it is modified. Unity can't handle prefabs with a hierarchy that is not the same as the prefab asset, therefore you always have to use the Apply button in the inspector to apply changes to the root prefab and all nested prefabs.

    Thanks for letting me know about this. I have received another report about this issue as well and I am working on fixing it.
     
  18. ldhongen1990

    ldhongen1990

    Joined:
    Dec 18, 2015
    Posts:
    61
    Hey there I was previewing your plugins (trial version) and it was throwing up some exceptions when I was attempting to restructure my game objects.


    when I did the following:

    1. Drag a prefab to a scene, we call it GameObject A
    2. Duplicate the same prefab instance in the scene, we call it GameObject B
    3. Use native untity function [GameObject->Break prefab instance] on B
    4. Now drag the broken prefab instance B and and add it as a child to the other unbroken prefab instance, so that the hirechy looks like this:
    A
    -->B
    5. Use native unity function "Apply" button on the inspector for A
    6. Gets error message.
     
  19. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    If you can keep it to one paragraph you have a winner. It's not easy because unity only has one apply so maybe explain what apply self is will solve having to even have a warning.

    In this case I just added a component, no hierarchy change so this shouldn't have happened, maybe one of the bugs you just fixed in nested assets.

    Note to everyone: Max sent me a beta for nested prefab which now handles nested assets. This means you can change your asset's hierarchy in Maya and it'll update all your prefabs!! It is such a breath of fresh air and completely changes the way I work.
     
  20. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Thank you for reporting this bug, the internally cached values were not updated completely after breaking the prefab connection. I have fixed it for the next update :)

    @laurentlavigne
    Components are also counted as a modified hierarchy unfortunately. The Apply Self button is explained in the documentation, maybe it will help.
     
  21. runelink

    runelink

    Joined:
    Jun 2, 2014
    Posts:
    4
    Hey, I'm just trying the trial and I'm running into an issue. These are the steps I'm doing:
    1. Make prefab from capsule
    2. Drag that prefab into an empty scene
    3. Create empty gameObject
    4. Drag the prefab into the empty gameObject
    5. Try to replace the capsule prefab with the empty gameObject that has the capsule inside by dragging it on the prefab in the project window
    When I do this the empty gameObject dissapears and it just turns into a single object again. If you try this without the nested prefab system it works just fine.
    I made a video of the steps as well but it was a lot of steps to record in 6 seconds :)
    https://i.gyazo.com/d5321209db828e20e53799c68e92cca7.mp4
     
  22. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @runelink
    Thank you for trying Nested Prefabs and thanks for reporting this bug. I have never thought about this workflow so I am glad you are pointing it out. It is indeed a bug and I have fixed it in the latest version, it should be available on the asset store (or trial version on the website) somewhere next week!
     
    runelink likes this.
  23. runelink

    runelink

    Joined:
    Jun 2, 2014
    Posts:
    4
    Good to hear. We might use this in the future so I'm just figuring out if it works with all our workflows, I'll let you know if I find any more issues!
     
    Visual-Design-Cafe likes this.
  24. ggevrin

    ggevrin

    Joined:
    Jan 8, 2013
    Posts:
    13
    Hello,

    We are using nested prefabs in our project, so far so good. We imported it few days ago into an existing project and we are facing the following issue :

    We have Editor scripts to build a room prefab made with tile prefabs (example : wall tiles). So the resulting room prefab contains several wall tile (nested) prefab instances. As you can imagine, each wall tile instance has its own properties (Transform of course but also other components properties values). When we save the room prefab, all wall tile instances need to retain its own properties values. It is basically an override.

    The Override component works well but we cannot afford to add and tweak manually an override component for each tile. We are considering 2 fixes :

    1 : Disconnect each instance from its prefab : maybe the easier

    2 : Automate adding an override component : this would be better as it would maintain prefab connection. I read you are working on a "do not consider this property" feature

    So :

    What would be your advice between these 2 solutions (or maybe a magical third one ?)

    I did not find your API documentation on your website, did I miss it ?

    How to break nested prefab connection (by code) : I guess there is something to do specific to your workflow ?

    Thanks in advance for your reply
     
  25. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @Ael-KHAN
    Thank you for using Nested Prefabs!
    The documentation for the API is not yet available I am afraid, however I will explain the API you can use for this situation to you. The best solution would be to either use option #2 and add overrides, or you can go for the magical third one which will give you the most control.
    In both cases the public API is not completely finished or exposed in the current release version, I will send you a download link for the latest beta version which has a public API available.

    1. I do not recommend breaking prefab connections. It is not possible to only break a prefab connection of a nested prefab. You have to either disconnect the entire prefab hierarchy using the standard 'PrefabUtility.DisconnectPrefabInstance' or you have to remove the nested prefab connection completely using 'NestedPrefabUtility.RemovePrefabConnection'.

    2: To add overrides through script you can use the code in the following example. In this example there should be a nested prefab with a Rigidbody component in your scene. If you select the nested prefab and choose 'Tools/Set Prefab Overrides' the mass of the Rigidbody will be overridden.
    Code (csharp):
    1.  
    2. /// <summary>
    3.     /// Sets the prefab overrides on the selected game object.
    4.     /// </summary>
    5.     [MenuItem( "Tools/Set Prefab Overrides" )]
    6.     public static void SetOverrides()
    7.     {
    8.         GameObject gameObject = Selection.activeGameObject;
    9.  
    10.         if( gameObject == null )
    11.             throw new System.NullReferenceException( "Selected object is null" );
    12.  
    13.         // Make sure the game object is a Nested Prefab.
    14.         if( gameObject.GetComponent<INestedPrefab>() == null )
    15.             throw new System.ArgumentException( "Prefab Overrides can only be set on a Nested Prefab" );
    16.  
    17.         // Make sure the game object has a PrefabOverrides component.
    18.         var overrides = gameObject.GetComponent<PrefabOverrides>();
    19.  
    20.         if( overrides == null )
    21.             overrides = gameObject.AddComponent<PrefabOverrides>();
    22.  
    23.         // Override the mass property of the Rigidbody component on the game object.
    24.         PrefabOverride prefabOverride = PrefabOverrideUtility.SetOverrideProperty(
    25.                                             overrides,
    26.                                             gameObject.GetComponent<Rigidbody>(),
    27.                                             "m_Mass",
    28.                                             true );
    29.  
    30.         // The value of the override is stored in the PrefabOverride itself so you have to make sure to set its value.
    31.         prefabOverride.SetValue( gameObject.GetComponent<Rigidbody>().mass );
    32.     }
    33.  
    Make sure to add the namespace to your class:
    Code (csharp):
    1. using VisualDesignCafe.Editor.Prefabs;
    3. The magical third option is adding a CustomProcessor that will process all modifications made to a prefab. You can make a custom processor by adding the CustomProcessor attribute to a class:
    Code (csharp):
    1. [CustomProcessor( typeof( IPrefab ) )]
    Inside the class you can add a method to postprocess the modifications:
    Code (csharp):
    1. public static Modification[] PostprocessModifications( IPrefab prefab, Modification[] modifications, IPrefab sourcePrefab )
    This method will be called for each modification made to a prefab, before they are actually applied to any nested prefabs.
    Here is an example postprocessor that will ignore:
    - modifications to the mass of a Rigidbody
    - Adding/Removing of BoxCollider components
    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using System.Linq;
    5. using UnityEngine;
    6. using UnityEditor;
    7.  
    8. using VisualDesignCafe.Editor.Prefabs;
    9.  
    10. [CustomProcessor( typeof( IPrefab ) )]
    11. public class PrefabPostprocessor
    12. {
    13.  
    14.     private delegate Modification ModificationProcessor( Modification modification, Component source, Component destination, Modification[] modifications );
    15.  
    16.     /// <summary>
    17.     /// A collection of custom postprocessor methods for each component type.
    18.     /// </summary>
    19.     private static Dictionary<System.Type, ModificationProcessor> _postProcessors = new Dictionary<System.Type, ModificationProcessor>()
    20.     {
    21.         { typeof(Rigidbody), OnPostprocess_Rigidbody },
    22.     };
    23.  
    24.     /// <summary>
    25.     /// Called after all modifications to a prefab have been found.
    26.     /// </summary>
    27.     /// <param name="prefab">The prefab that will be modified with the modifications.</param>
    28.     /// <param name="modifications">An array of modifications found.</param>
    29.     /// <param name="sourcePrefab">The prefab that was used to compare against to find the modifications.</param>
    30.     /// <returns>A (modified) array of modifications.</returns>
    31.     public static Modification[] PostprocessModifications( IPrefab prefab, Modification[] modifications, IPrefab sourcePrefab )
    32.     {
    33.         for( int i = modifications.Length - 1; i > -1; i-- )
    34.         {
    35.             Modification modification = modifications[i];
    36.  
    37.             switch( modification.Type )
    38.             {
    39.                 case ModificationType.PropertyValueChanged:
    40.                     modifications[i] = PostprocessPropertyValueChanged( modifications[i], modifications );
    41.                     break;
    42.                 case ModificationType.ComponentAdded:
    43.                 case ModificationType.ComponentRemoved:
    44.  
    45.                     // If a component needs to be ignored it is best to use the [DontSaveInPrefab] attribute.
    46.                     // However for Unity components it is possible to remove them here.
    47.                     if( ( modifications[i].DestinationObject ?? modifications[i].SourceObject ).targetObject is BoxCollider )
    48.                         modifications[i] = null;
    49.  
    50.                     break;
    51.             }
    52.         }
    53.  
    54.         return modifications.Where( m => m != null ).ToArray();
    55.     }
    56.  
    57.     /// <summary>
    58.     /// Called for each changed property in a component.
    59.     /// </summary>
    60.     /// <param name="modification"></param>
    61.     /// <param name="modifications"></param>
    62.     /// <returns></returns>
    63.     private static Modification PostprocessPropertyValueChanged( Modification modification, Modification[] modifications )
    64.     {
    65.         // Get the component in which the property value was changed.
    66.         // The targetObject can also be a GameObject if a property such as the game object name was changed.
    67.         // Only changes to a component are handled here, game objects are ignored.
    68.         Component component = modification.SourceObject.targetObject as Component;
    69.  
    70.         if( component == null )
    71.             return modification;
    72.  
    73.         // Find a processor for the component type.
    74.         ModificationProcessor processor;
    75.         if( !_postProcessors.TryGetValue( component.GetType(), out processor ) )
    76.             return modification;
    77.  
    78.         // Call the processor with the modification. It will return the modified modification.
    79.         modification = processor(
    80.                             modification,
    81.                             modification.SourceObject.targetObject as Component,
    82.                             modification.DestinationObject.targetObject as Component,
    83.                             modifications );
    84.  
    85.         return modification;
    86.     }
    87.  
    88.     /// <summary>
    89.     /// Called for each changed property in a Rigidbody component.
    90.     /// </summary>
    91.     /// <param name="modification"></param>
    92.     /// <param name="source"></param>
    93.     /// <param name="destination"></param>
    94.     /// <param name="modifications"></param>
    95.     /// <returns></returns>
    96.     private static Modification OnPostprocess_Rigidbody( Modification modification, Component source, Component destination, Modification[] modifications )
    97.     {
    98.         if( source == null || destination == null || modification == null )
    99.             return modification;
    100.  
    101.         // Print the changed property to the console.
    102.         Debug.Log( string.Concat(
    103.                             source.GetType().FullName,
    104.                             ".",
    105.                             modification.SourceProperty.propertyPath,
    106.                             " (",
    107.                             modification.SourceProperty.propertyType,
    108.                             ")" ) );
    109.  
    110.         // Ignore changes to the mass of a Rigidbody.
    111.         if( modification.SourceProperty.propertyPath == "m_Mass" )
    112.             return null;
    113.  
    114.         return modification;
    115.     }
    116.  
    117. }
    118.  
     
  26. kritchie

    kritchie

    Joined:
    Mar 17, 2013
    Posts:
    7
    So far this asset as worked out much better than other solutions I've tried.

    But I'm getting extremely long pauses after "Applying" prefabs. Between 10-20 seconds. This is with about 1000 different prefabs in my project.

    I don't know for sure if this is because of Nested Prefabs, but it never happened before. Is there anything I could check to see what's going on here? It's quite aggravating.
     
  27. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @kritchie
    Thank you for using Nested Prefabs! The 10-20 seconds delay when Applying prefabs was caused due to searching for nested prefab connections in the project. This behavior has been improved in the latest version (1.2.1). The nested prefab connections are now cached the first time you apply changes after starting up the editor. After the first apply there should be no delay at all anymore.

    Version 1.2.1 was just accepted to the Asset Store a few hours ago so you should be able to download it now!
     
  28. T_Strijker

    T_Strijker

    Joined:
    Jun 24, 2013
    Posts:
    18
    Hello,

    I have tested your free trail in our project large project. The plugin seems give use easy whey to work with nested prefabs but has a performance issue when duplicating a nested object (using ctrl + d) under a prefab. The Unity CPU and memory use shoot up until I select a other game object in the scene. This makes designing of the level very slow process. Until this is fixed we can't use the Nested Prefab plugin for our projects.
     
  29. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @T_Strijker
    Thank you for trying out Nested Prefabs!
    That is a strange issue, I have not been able to reproduce it anywhere.
    Which version of Unity are you using? And are you using any custom scripts on the prefab(s)?
     
  30. _sten_

    _sten_

    Joined:
    Mar 25, 2013
    Posts:
    1
    Is it possible to add event listener to a button (Button.ButtonClickedEvent) using "Prefab Overrides"?
     
  31. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @_sten_
    Yes, it is possible to add an On Click event with prefab overrides.
    To do this you have to add an empty On Click event to the original prefab and then add two overrides for the Target and Method Name of the event. These properties can be found at 'Button/On Click/Persistent Calls/Calls/Element 0/' when clicking 'Add Override'.

    button_onclick_override.jpg
     
  32. T_Strijker

    T_Strijker

    Joined:
    Jun 24, 2013
    Posts:
    18
    Where using Unity 5.6.0p3. Look at the object that I was trying to duplicate it had a LOD group script on it. I also tried to replicate the issues today but could also not reproduce it and looks like that the plugin is working correctly at the moment. Gone test it some more to see it our team can use this plugin :).
     
    Visual-Design-Cafe likes this.
  33. andympage101

    andympage101

    Joined:
    Jun 7, 2013
    Posts:
    12
    This is working great so far. Is there any way to stop caching the prefab database every time the editor is started? I imagined this would only occur once the plugin has been first installed or there is a update etc. Thanks
     
  34. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @andympage101
    For now the cache has to be rebuilt every time the editor starts. This is done so it can work nicely with version control. If the cache is not rebuilt it is possible that the project will become corrupt if it has been updated and prefabs have been added/removed outside of Unity (through version control).

    I'll do some more research and testing on this subject and see if I can come up with a safe system that allows the cache to be saved in between editor sessions. But unfortunately I can't promise any changes at the moment.
     
  35. ggevrin

    ggevrin

    Joined:
    Jan 8, 2013
    Posts:
    13
    Tank you for your answer. It is crystal clear.
    Meanwhile, we continued to work with Nested Prefabs on one of our current projects. We are encountering some weird issues related to prefabs but I cannot say Nested prefabs can be incriminated. On the other hand, I get the following error when opening my project with Unity :
    From what I can see, my project is still working but I am not comfortable about having an error on an asset as important as Nested Prefabs on each startup.
    Have you any explanation about what is happening ?
    Thanks in advance for your answer
     
  36. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @Ael-KHAN
    It is a known error and has been fixed in the latest version, it should already be available for download on the asset store.

    Occasionally a component does not exist when trying to remove it, the internal RemoveComponent method was a bit too strict and threw an error if the component was already removed, which is totally unnecessary. The latest version should no longer throw an error in this case.
     
  37. ggevrin

    ggevrin

    Joined:
    Jan 8, 2013
    Posts:
    13
    Thank you for your fast reply
     
  38. Smashy

    Smashy

    Joined:
    May 31, 2013
    Posts:
    1
    Hi, I've just upgraded to the paid version as I'm finding it an invaluable asset! However I'm getting this error when I start Unity: "Nested Prefabs is in build mode. Prefabs should not be edited while in build mode."

    I hadn't noticed it in the trial but now I have the "Build Mode" dialogue across the scene view in the paid version. Attempting to Postprocess the build as per instructions fails (with "Failed to load prefab database").

    I've rolled back and even done a complete reinstall but still have the error.
     
  39. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @Smashy
    Thank you for using Nested Prefabs!

    You have most likely upgraded to the newer version while the project was in Build Mode and the exported Prefab Database is not compatible with this version. If your project looks fine besides the "Build Mode" dialogue (if your prefabs look fine) then you can delete the "PrefabDatabase" file in the "Library" folder of your project. This will manually get you out of build mode.

    If you can't do this because some of the prefabs in your project are not correct you can try to install the previous version, then go out of Build Mode by postprocessing the project (Assets/Nested Prefabs/Postprocess build) and then upgrading again to the latest version.

    If both don't work then please send the "PrefabDatabase" file to me and I'll manually process it to remove any issues with the file that cause the "Failed to load prefab database" error. In this case also please let me know if you see any errors in the console when this error dialogue appears.
     
  40. Alienniki

    Alienniki

    Joined:
    Nov 2, 2016
    Posts:
    7
    "PrefabDatabase" file not found in my Library folder. I switch to postprocess in Assts menu. I get Error dialog with text: "Failed to postprocess the project after a build." In console: "
    Failed to load prefab database.
    UnityEngine.Debug:LogError(Object)
    VisualDesignCafe.Editor.Prefabs.Database.BuildPostprocessor:Abort(String)
    VisualDesignCafe.Editor.Prefabs.Database.BuildPostprocessor:OnPostprocessBuild()
    VisualDesignCafe.Editor.Prefabs.Database.PrefabDatabaseUtility:postprocessBuild()
    VisualDesignCafe.Editor.Prefabs.Database.PrefabDatabaseMenu:postprocessBuild()"

    I remove folder "Nested Prefabs" in Runtime\Plugins. Unity editor diplay diaog "Uninstall Nested Prefabs?". I ckicked "Uninstall". After uninstall, I installing Nested Prefabs again. I see dialog "Nested Prefabs successfully installed". I ckick Ok and see "Build Mode"
     
  41. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @Alienniki
    It looks like the internal 'Build Mode' variable is not reset because the prefab database failed to load. Please import this script into an Editor folder in your project and go to 'Nested Prefabs/Exit Build Mode' in the menu to manually go out of build mode:

    Code (CSharp):
    1. using UnityEditor;
    2. using VisualDesignCafe.Editor.Prefabs.Database;
    3.  
    4. public class ExitBuildMode
    5. {
    6.     [MenuItem( "Nested Prefabs/Exit Build Mode" )]
    7.     public static void Exit()
    8.     {
    9.         var setIsPreprocessed = typeof( PrefabDatabaseUtility ).GetMethod( "SetIsPreprocessed", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic );
    10.         setIsPreprocessed.Invoke( null, new object[] { false } );
    11.     }
    12. }
    13.  
     
  42. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    244
    Hey i'm getting an issue with some of my prefabs showing pink icon and some are blue, yet both are the root. What would cause this?
    upload_2017-6-30_13-41-19.png

    Also, if i make a change to the "PlayerShield" it will save the parent object "Player Shield (##)" as well which is not what I want. So to make a change I have to drag out the prefab from the project and make my changes then apply. it will apply those changes but I'm getting the weird result from picture above....What am i doing wrong?

    The reason I have the hierarchy like that as well is because PropertyOverrides can't be applied to the root. So as a work around we just created an empty gameobject. It's not ideal, but its working for now.
     
    Last edited: Jun 30, 2017
  43. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @Brogan89
    That is a strange issue.
    First of all please make sure you have the latest version (1.2.2) which was just released. There have been some internal fixes in finding the prefab root, which might be causing the icon colors.

    In this situation which prefabs have a Prefab Overrides component? If all of them are root prefabs then it should not be possible add any overrides to them. Adding an empty GameObject as parent shouldn't have any influence.

    Could you share a screenshot of the entire hierarchy all the way up until the root GameObject in the scene? It almost looks like all the prefabs in the screenshot are actually nested and there is a root prefab somewhere up in the hierarchy but not all of the nested prefabs have been applied yet.
     
  44. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    244
    @Visual-Design-Cafe thanks for the fast reply. I did update to 1.2.2 i think it was 2 days ago. I couldn't confirm anyway a build version number in the asset folder...
    upload_2017-6-30_16-7-50.png
    Above is the entire hierarchy to the prefab.

    I probably didn't explain myself well enough. I'm not using property overrides because it wasn't supported for the root, so we added the script we want to be different in the parent gameObject. I could probably create a prefab of that, and then use the child to apply property overrides, but I've already done all the work :) There are 46 of the "PlayerSheld" prefabs.
     
  45. Sarudan

    Sarudan

    Joined:
    May 21, 2011
    Posts:
    65
    Hi, we've just purchased Nested Prefabs, and I'm noticing that it is taking an extremely long time to install. It's been 2 hours so far, and it's only 20% of the way through checking models. What is it doing during this phase that could be taking so long? Our project is around 100GB in size (MMORPG), so we have quite a lot of assets.

    I certainly hope this process is a once off.
     
  46. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @Wumpee
    During the install all prefabs and models are reimported (this is what takes so long) and some internal data is added (such as unique ID's for every object). If your project is that large it can indeed take a while. It only has to be done once though, after it has been installed you won't have to go through this process again.

    @Brogan89
    Thanks for sharing the screenshot. It does look like a bug, I'll see if I can reproduce it in a debug project. If not I'll send you some debug scripts so you can debug the prefabs in your project.
     
    Brogan89 likes this.
  47. Sarudan

    Sarudan

    Joined:
    May 21, 2011
    Posts:
    65
    Thanks for the prompt reply,

    I'm assuming this reimport will have to happen for all team members? That's going to be quite an interruption. Even a full project reimport doesn't take this long under normal circumstances such as when upgrading to a new version of Unity.
     
  48. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Yes, all team members will have to do a reimport. The reason it is slower than a regular full project import is because it reimports all models one-by-one, while reimporting the project will batch all reimports. This is done so any errors can be caught while installing without terminating the entire install process.

    If you want to speed it up you can force quite Unity after the installation has started and manually reimport all prefabs and models. It is a bit of a hacky method but should be completely safe, the only important point during installation is that all prefabs and models get reimported, the method you use to reimport doesn't matter.
     
  49. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    After one machine completes the reimport, copy the entire project folder over to the other computers including Library, this should work.
     
  50. Alienniki

    Alienniki

    Joined:
    Nov 2, 2016
    Posts:
    7
    Thanks. I found registry key in Windows Registry and remove it.