Search Unity

Nested Prefabs: Fully integrated, Completely automatic

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

  1. IgorAherne

    IgorAherne

    Joined:
    May 15, 2013
    Posts:
    393
    Hey, after re-moving the nestedPrefabs, many of gameObjects in scenes have components that show up as not-recognized (missing reference) and null. Removing them works, however they re-appear on the same gameObjects after the project was re-started. That happens even if the project is saved & full re-import of assets happens

    These null components are on the prefabs as well, not just on the gameObjects in the scene

    Iterating over components of gameObjects using UnityEditorInternal.ComponentUtility does return entries that are null
    This helper-code doesn't resolve it :(

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEditor;
    5.  
    6. public class FixNullComponents_onGOs : Editor {
    7.  
    8.         [MenuItem("Tools/Fix Null Components on GOs, recursive")]
    9.  
    10.     public static void FixNullComponents_onGOs_inEditor_recursive() {
    11.         if(Selection.activeTransform == null) {
    12.             Debug.Log("please select at least one gameObject");
    13.             return;
    14.         }
    15.  
    16.         for(int i =0; i< Selection.transforms.Length; ++i) {
    17.             Fix_recursive(Selection.transforms[i]);
    18.         }
    19.     }
    20.  
    21.     //sometimes, there can be a bug, where a gameObject contains a reference to a null component
    22.     public static void Fix_recursive(Transform transf) {
    23.         for(int i = 0; i<transf.childCount; ++i) {
    24.             Fix_recursive( transf.GetChild(i) );
    25.         }
    26.             // We must use the GetComponents array to actually detect missing components
    27.             var components = transf.GetComponents<Component>();
    28.      
    29.             // Create a serialized object so that we can edit the component list
    30.             var serializedObject = new SerializedObject(transf.gameObject);
    31.             // Find the component list property
    32.             var prop = serializedObject.FindProperty("m_Component");
    33.      
    34.             // Track how many components we've removed
    35.             int r = 0;
    36.      
    37.             // Iterate over all components
    38.             for(int j = 0; j < components.Length; j++)
    39.             {
    40.                 // Check if the ref is null
    41.                 if(components[j] == null)
    42.                 {
    43.                     // If so, remove from the serialized component array
    44.                     prop.DeleteArrayElementAtIndex(j-r);
    45.                     // Increment removed count
    46.                     r++;
    47.                 }
    48.             }
    49.      
    50.             // Apply our changes to the game object
    51.             serializedObject.ApplyModifiedProperties();
    52.             UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(transf.gameObject.scene);
    53.      }
    54.  
    55.  
    56. }
    57.  

    NestedPrefabs was uninstalled from the project, and in the process of it showed progress bar which went to 100%, and all the NestedPefabs dlls, etc seemed to be successfully removed, but these null components keep showing up here and there :/


    Using Unity 2017.1f, with Collab

    Thanks!
     
    Last edited: Oct 5, 2017
  2. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    When the scene is saved Unity will also save all prefabs that have any changes to them. These prefabs have to be processed by the Nested Prefabs plugin as well, which can cause a delay. Usually, this shouldn't take long and only happens for nested prefabs that have been modified. However, it is possible that some scripts in your project mark prefabs as dirty.

    Can you try to import the script that was posted earlier in this thread and see which prefabs are being imported when you save the scene? If there are a lot of seemingly unrelated prefabs being saved then please check if they contain any scripts that run in edit-mode and if those scripts modify any properties of the prefab.

    Also, can you let me know roughly how long the delay is? And do you see any progress bar, such as a 'Caching Prefab Database' bar?
     
  3. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Sorry to hear it is not working for you. That attribute (and some others) is mostly intended for internal use, so they might not work for every use case. What you are describing 'should' be possible to implement in the background. If you want then can you send me some screenshots of your prefabs, prefab hierarchy, and what data you want to save where exactly? Then I'll see if I can add an option or attribute for this use-case. (please note that it might not be entirely possible due to limitations of Unity. Though, I'll do my best) You can send me a PM or an email to support@visualdesigncafe.com
     
  4. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    It might be caused by Collab in this case. During uninstall, all internal components will be removed from the prefabs in your project. This will mark them as dirty so they will have to be pushed to Collab. If you don't push them and then later revert a prefab or scene, the components will come back. But because Nested Prefabs is no longer included in the project, the components will show up as missing scripts. Can you make sure that all prefabs and scenes are pushed after uninstalling?

    Please let me know if that doesn't work and I'll send you a script to clean your project of any components with missing scripts.
     
  5. Deleted User

    Deleted User

    Guest

    I have issues with git and Nested Prefabs. Re-saving existing prefabs added some hidden components, which is totally fine as the plugin would probably not work without them. However, when further changes are done to the prefabs, the hidden components change their hide flags (shown in text version of saved prefabs as m_ObjectHideFlags). It was trying to change the value to 11 from a value of 1.

    I figured that commiting new values of 11 to all such components would get rid of the problem for good. However, now, after saving prefabs, several occurrences of the hideflags are changing the value back to 1 from a (commited) value of 11.

    This is annoying and clutters git diffs when commiting/merging etc. Please fix it. I'm using the newest version (1.2.5 at the time of writing).

    Thanks
     
  6. LuckyMDI

    LuckyMDI

    Joined:
    Jun 1, 2017
    Posts:
    11
    Hi again. After a long absence, my team is back on the project using your plugin and wanted to let you know it's going pretty well so far.

    I am, however, running into an exception that might related to rendering the little icon beside a nested prefab with an overridden property. Here's the bug report.
    Message: "IndexOutOfRangeException: Array index is out of range."
    Version: "1.2.5.43"
    Unity Version: "2017.2.0f2 (472de62575d5)"
    StackTrace: [
    VisualDesignCafe.Editor.Prefabs.NestedPrefabHierarchyWindow.DrawOverrides (Rect rect, UnityEngine.GameObject currentObject, IPrefab prefab, VisualDesignCafe.Editor.Prefabs.PrefabOverrides properties, Int32 depth)
    VisualDesignCafe.Editor.Prefabs.NestedPrefabHierarchyWindow.DrawOverrides (Rect rect, UnityEngine.GameObject currentObject)
    VisualDesignCafe.Editor.Prefabs.NestedPrefabHierarchyWindow.HierarchyWindowItemOnGUI (Int32 instanceID, Rect rect)
    UnityEngine.Debug:LogException(Exception)
    VisualDesignCafe.Editor.Prefabs.NestedPrefabHierarchyWindow:HierarchyWindowItemOnGUI(Int32, Rect)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
    ]
     
  7. LuckyMDI

    LuckyMDI

    Joined:
    Jun 1, 2017
    Posts:
    11
    I believe I may have been misusing the prefab overrides. Trying it again this morning, the error appears to have gone away.
     
  8. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Those hidden components are indeed required for the plugin to work. They should all have a hideflags value of 11. We have had some issues with saving these hideflags in the past that we thought was fixed by now. Apparently, there are still some issues with them so I'll make sure to look into it again. I am not sure at the moment what the problem is with these hideflags, so I can't give you an exact timeline on when it will be fixed. My apologies for any inconvenience caused. I'll keep you updated with any information regarding this issue.
     
  9. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Could you provide some more information about how you were using the overrides? The exception you saw should not happen, no matter what you do with overrides, and I can't reproduce it as well. It would be great if I can be able to reproduce it with some additional information.
     
  10. inkyphilospher

    inkyphilospher

    Joined:
    Aug 26, 2014
    Posts:
    13
    Hi, we tried to use nested prefabs and loved the implementation, but had to discontinue working using it due to the long load times (most likely due to the large number of prefabs and files in the project). We are similarly running into missing scripts issues. I don't think it's the Collab service, as we don't utilize it very often, and don't push scene assets at all.

    Would it be possible to get that removal script? Or is there another avenue I'm missing.
     
    IgorAherne likes this.
  11. sketchygio

    sketchygio

    Joined:
    Nov 6, 2014
    Posts:
    31
    Still getting to know the plugin but I'm having some trouble adding the Prefab Overrides to some gameobjects, though I'm not sure why. Is there a certain criteria needed for the component to be addable to the prefab?
     
  12. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Thank you for using Nested Prefabs. Prefab Overrides can only be applied to a nested prefab, and not to the root of a prefab or any other child within a prefab. Please take a look at the following image as an example. The Prefab Overrides component can only be added to the selected nested "Prefab B". Adding it to any other object will result in a warning and the component will be removed.
    prefab_overrides_target.jpg
     
  13. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Too bad to hear that Nested Prefabs had too long load times in your project. Can you let me know roughly how many prefabs you have in your project? And did the apply time itself cause delays, or was it because of caching the prefab database (it shows a progress bar for this)? We are currently working on improving the performance for very large projects.

    You should be able to clean up your project with the following script. Please note that it can take a while to clean the entire project. You can choose "Remove Missing Script From Project" in the "Component" menu after importing the script.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using System.Linq;
    4.  
    5. using UnityEditor;
    6. using UnityEditor.SceneManagement;
    7. using UnityEngine;
    8. using UnityEngine.SceneManagement;
    9.  
    10. public class ProjectCleaner
    11. {
    12.  
    13.     [MenuItem( "Component/Remove Missing Scripts From Project" )]
    14.     public static void RemoveMissingScriptsFromProject()
    15.     {
    16.         EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
    17.  
    18.         if( !CleanPrefabAssets() || !CleanScenes() )
    19.         {
    20.             Debug.Log( "Canceled by user." );
    21.             EditorUtility.ClearProgressBar();
    22.             return;
    23.         }
    24.  
    25.         AssetDatabase.SaveAssets();
    26.         EditorUtility.ClearProgressBar();
    27.     }
    28.  
    29.     private static GameObject[] FindPrefabsInProject( System.Action<float> progressCallback )
    30.     {
    31.         string[] assets = AssetDatabase.GetAllAssetPaths()
    32.             .Where( p => p.EndsWith( ".prefab", System.StringComparison.OrdinalIgnoreCase ) )
    33.             .ToArray();
    34.  
    35.         GameObject[] prefabs = new GameObject[ assets.Length ];
    36.  
    37.         for( int i = 0; i < assets.Length; i++ )
    38.         {
    39.             prefabs[ i ] = AssetDatabase.LoadAssetAtPath( assets[ i ], typeof( GameObject ) ) as GameObject;
    40.  
    41.             if( progressCallback != null )
    42.                 progressCallback( (float) i / (float) assets.Length );
    43.         }
    44.  
    45.         return prefabs
    46.                 .Where( p => p != null )
    47.                 .ToArray();
    48.     }
    49.  
    50.     private static bool CleanPrefabAssets()
    51.     {
    52.         GameObject[] prefabs = FindPrefabsInProject( ( float progress ) =>
    53.         {
    54.             EditorUtility.DisplayProgressBar(
    55.                         "Hold On",
    56.                         "Finding prefabs in project",
    57.                         progress );
    58.         } );
    59.         int count = prefabs.Length;
    60.         int index = 0;
    61.  
    62.         AssetDatabase.StartAssetEditing();
    63.         {
    64.             foreach( GameObject prefab in prefabs )
    65.             {
    66.                 try
    67.                 {
    68.                     if( EditorUtility.DisplayCancelableProgressBar(
    69.                         "Removing components with a missing script",
    70.                         AssetDatabase.GetAssetPath( prefab ),
    71.                         (float) ( index++ ) / (float) count ) )
    72.                     {
    73.                         return false;
    74.                     }
    75.  
    76.                     GameObject instance = PrefabUtility.InstantiatePrefab( prefab ) as GameObject;
    77.  
    78.                     CleanObjectRecursive( instance );
    79.  
    80.                     PrefabUtility.ReplacePrefab( instance, prefab );
    81.                     GameObject.DestroyImmediate( instance );
    82.                 }
    83.                 catch( System.Exception e )
    84.                 {
    85.                     Debug.LogException( e );
    86.                 }
    87.             }
    88.         }
    89.         AssetDatabase.StopAssetEditing();
    90.         AssetDatabase.SaveAssets();
    91.  
    92.         return true;
    93.     }
    94.  
    95.     private static bool CleanScenes()
    96.     {
    97.         string[] sceneList = AssetDatabase.GetAllAssetPaths()
    98.             .Where( path => path.EndsWith( ".unity" ) )
    99.             .ToArray();
    100.  
    101.         Scene activeScene = EditorSceneManager.GetActiveScene();
    102.  
    103.         int count = sceneList.Length;
    104.         int index = 0;
    105.  
    106.         for( int i = 0; i < sceneList.Length; i++ )
    107.         {
    108.             try
    109.             {
    110.                 if( EditorUtility.DisplayCancelableProgressBar(
    111.                         "Removing components with a missing script",
    112.                         sceneList[ i ],
    113.                         (float) ( index++ ) / (float) count ) )
    114.                 {
    115.                     return false;
    116.                 }
    117.  
    118.                 Scene scene = EditorSceneManager.GetSceneByPath( sceneList[ i ] );
    119.  
    120.                 if( !scene.isLoaded )
    121.                     scene = EditorSceneManager.OpenScene( sceneList[ i ], OpenSceneMode.Additive );
    122.  
    123.                 CleanScene( scene );
    124.  
    125.                 EditorSceneManager.SaveScene( scene );
    126.  
    127.                 if( scene != activeScene )
    128.                     EditorSceneManager.CloseScene( scene, true );
    129.             }
    130.             catch( System.Exception e )
    131.             {
    132.                 Debug.LogException( e );
    133.             }
    134.         }
    135.  
    136.         return true;
    137.     }
    138.  
    139.     private static void CleanScene( Scene scene )
    140.     {
    141.         GameObject[] rootGameObjects = scene.GetRootGameObjects();
    142.         foreach( GameObject gameObject in rootGameObjects )
    143.         {
    144.             CleanObjectRecursive( gameObject );
    145.         }
    146.     }
    147.  
    148.     private static void CleanObjectRecursive( GameObject gameObject )
    149.     {
    150.         if( gameObject.transform.parent != null )
    151.         {
    152.             Debug.LogWarning( "GameObject is not a root object" );
    153.             return;
    154.         }
    155.  
    156.         Transform[] hierarchy = gameObject.GetComponentsInChildren<Transform>( true );
    157.         foreach( Transform child in hierarchy )
    158.         {
    159.             var serializedChild = new SerializedObject( child.gameObject );
    160.             var serializedComponentList = serializedChild.FindProperty( "m_Component" );
    161.             var components = child.GetComponents<Component>();
    162.  
    163.             for( int i = components.Length - 1; i > -1; i-- )
    164.             {
    165.                 if( components[ i ] != null )
    166.                     continue;
    167.  
    168.                 serializedComponentList.DeleteArrayElementAtIndex( i );
    169.             }
    170.  
    171.             serializedChild.ApplyModifiedPropertiesWithoutUndo();
    172.         }
    173.     }
    174.  
    175. }
    176.  
     
    Last edited: Mar 4, 2018
  14. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    @Visual-Design-Cafe
    Hi, We are doing an RPG game with you know complex UIs. Our current UI shows a list of character image, name, description and stats.

    Now interesting thing is, whole list item is being used in multiple places somewhere with title and descriptiononly, somewhere with stats only, somewhere with different type of stats (each stat item shows an icon too), somewhere with picture and title only, you get the idea.

    So here is a picture in my mind to use your plugin, as im new so please advise if doing something stupid

    - Stat Prefab made of text and icon (both are TMPro labels, and icon is using fontawesome)
    - Confused Here, Multiple Stats Prefabs with Label Overrides (Icon n Text). Can i save prefab with label override as another prefab? so 1 base stat item prefab, and 10 label icon ovveride stat prefabs).
    - Stat Container Prefab (which will layout stats) so in future if i chane layout padding, spacing, alignment etc This prefab will hold different stat prefabs on different places
    - Base Container with Title, Image, Stat Descripton, and then seperate prefabs one with title and image, one with tile description etc

    Please advise
     
  15. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Please take a look at the example image below.
    You can create a base Stat prefab with the text and icon ("Stat-Base"). Then you can create a new empty parent object for it and save that new root as a prefab ("Stat-A" ). You will then have a prefab with the base stat as a nested prefab. To this nested prefab you can add overrides to change the text and icon for each variation. You can then save the prefab ("Stat-A") as many times as you want to create multiple variations ("Stat-B", "Stat-C", "Stat-D", etc.). Each variation will contain the original Stat prefab as nested prefab so it will be updated with any changes you make to it.



    After creating these variations, you can nest them in a Layout prefab. The prefab is using a Vertical Layout Group here to list all the stats, but you can, of course, use whatever layout you require.



    You can repeat the same process that you used to create variations for each stat to create a container with variations.
    First, create a container prefab that holds the Stats Layout, title, image, and description.



    Second, you can create a variation by adding an empty parent object and saving it as a new prefab. You can override the "Is Active" state for the Title, Image, and Description to enable/disable them for each variation of the container.

     
    jGate99 likes this.
  16. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Thank you for your detailed explanation, it all makes sense now.
     
  17. Deleted User

    Deleted User

    Guest

    Not a big deal, but dragging a modified prefab with unsaved changes out of a nested prefab resets the dragged prefab to its state saved in the prefab. Here's a gif to show this.


    BTW, where should I be posting these bugs? Is it fine here or is there a bugtracker I can submit it to?

    Thanks
     
  18. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Thanks for reporting this. This issue happens because Unity automatically reloads the prefab when it is (re)connected to the asset after dragging it out of the hierarchy. We will look into it to see if there is a workaround for this.

    Yes, posting bugs here is totally fine. We don't have a public issue tracker at the moment (one is coming soon though)
     
  19. AntonLind

    AntonLind

    Joined:
    Jan 2, 2017
    Posts:
    3
    Hi!
    I just started using this, and it seems great. I have one question though. Why is "prefab overrides" restricted to nested prefabs? It would be useful to have override on "single layer" prefabs as well, to avoid propagating unwanted changes
     
  20. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Thanks for using Nested Prefabs! The reason that "prefab overrides" are restricted to nested prefabs is that the nested prefabs are handled by the plugin, while the root prefabs are applied automatically by Unity. If you use prefab overrides for the root prefab then Unity will automatically apply the overridden values. Since it happens internally in Unity there is no way to prevent this and there is no workaround. Therefore, we can't support prefab overrides for the root and only for nested prefabs. I hope this makes sense :)

    So, for root prefabs, you have to use the regular Unity way of overriding the property in the inspector (so it has a bold font) and then not applying it.
     
  21. AntonLind

    AntonLind

    Joined:
    Jan 2, 2017
    Posts:
    3
    I see, that makes sense. Thx!
     
  22. AntonLind

    AntonLind

    Joined:
    Jan 2, 2017
    Posts:
    3
    It seems like you can't have differing hierarchies of prefabs with this plugin, but maybe I'm missing something. I want to use the plugin to construct popup "components"(=prefabs) that can be re-used and tweaked for different scenarios.
    Let's say I have prefab A and B. I then construct my nested popup prefab:
    -POPUP
    ---A
    -----B

    Now I can not apply this hierarcy to the "POPUP" prefab, without also adding B to the A prefab. But in another scenario I might want to use A without B as a child. Is there any way to get around this?
     
  23. sboxle

    sboxle

    Joined:
    Sep 27, 2014
    Posts:
    8
    Hi VDC!
    Pleased to report we released our game since our last chat :) Cheers for your help

    Anyway, I've got the latest install and one prefab that's nested elsewhere keeps causing this prompt: "Prefab contains unregistered children. Please try reimporting the prefab asset."

    I've tried reimporting the asset by right click>reimport and it still has a '?' on the prefab when in scene.

    Is there another way to reimport that'll fix this? Also tried applying it while a child or the prefab itself etc.
     
    Visual-Design-Cafe likes this.
  24. mmcclure

    mmcclure

    Joined:
    Mar 14, 2017
    Posts:
    3
    Hi @Visual-Design-Cafe ,

    I'm having an issue during build. I've tried leaving the scene as-is and running the build, and pre-processing before building, and still can't get a successful build. I receive the following error (running 2017.2.0f3):


    ArgumentException: The Assembly UnityEditor is referenced by NestedPrefabs_Editor ('Assets/Nested Prefabs/NestedPrefabs_Editor.dll'). But the dll is not allowed to be included or could not be found.
    UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List`1 alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary`2 cache, BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:142)
    UnityEditor.AssemblyHelper.FindAssembliesReferencedBy (System.String[] paths, System.String[] foldersToSearch, BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:179)
    UnityEditor.HostView:OnGUI()

    Thanks for any help you can offer!
    --Matt

    EDIT: Turns out something was set to read-only. Problem solved.
     
    Last edited: Nov 6, 2017
  25. mmcclure

    mmcclure

    Joined:
    Mar 14, 2017
    Posts:
    3
    Different issue! I'm not seeing any performance benefit to using nested prefabs at all. Do the prefabs inside prefabs still reference their original prefabs? Or do they still become a part of their parent, as things work in standard Unity prefabs?
     
  26. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    244
    Run time performance is unaffected because it is an editor tool.
    Answer to question two is yes to both. They are apart of the parent, and their own instance. If you make a change to one, it will change everywhere, even if it is nested. It's the kind of magic that was banned in mid 1500s.
     
    mmcclure likes this.
  27. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    That is correct, if you add prefab B as a child of prefab A then it will be added to prefab A everywhere. It is the way how nested prefabs work in general, not only this plugin. I recommend keeping both prefab A and B as a direct child of POPUP, or creating two variants of prefab A: one with prefab B as a child and one without.
     
  28. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Congratulations on the release!

    Can you please try all four options described on this page next to the 'missing child' icon: https://www.visualdesigncafe.com/nestedprefabs/documentation/icons/
    One of them should usually work. If none of them work then please send a PM or email to support@visualdesigncafe.com with a screenshot of the prefab hierarchy and/or the prefab asset itself and I'll see what I can do for you.
     
  29. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    There is indeed no runtime performance benefit as it is an editor-only tool. All nested prefabs are part of the root prefab and are still regular Unity prefabs. Unfortunately, with the current limitations of Unity it is not possible to get true nested prefabs at runtime and the focus here is to improve the workflow in the editor.
     
  30. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    @Visual-Design-Cafe
    I finally got time to use Nested Prefab with Prefab Overrides and Oh Man, i am super impressed. Please tell me you have plans to keep updating it until Unity come up with their own variation. As i really want to convert my projects to your plugin to ease in development.
    Thanks once again for this wonderful.
     
    Visual-Design-Cafe likes this.
  31. mmcclure

    mmcclure

    Joined:
    Mar 14, 2017
    Posts:
    3
    Thanks for the response! Bummer that it's editor-only, but so it goes. The tool works like a dream, but the reason I tested it was the hope of a performance boost from maintaining all of the original prefab instances. So it goes! :)
     
  32. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Thanks, glad to hear you like it! :)
    Yes, we will continue updating Nested Prefabs until Unity comes up with something. There are still plenty of features and improvements planned.
     
    jGate99 likes this.
  33. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945

    As i mentioned earlier that this strategy simply works, however the only down side i see is that extra parent object to create a new nested prefab, which could cause some performance issues, For now its fine but any plans for future to improve this.
     
  34. BazookasZerreth

    BazookasZerreth

    Joined:
    Dec 8, 2016
    Posts:
    17
    Nested prefabs started acting up today for us and won't apply anymore:

    Code (CSharp):
    1.  
    2. Nested Prefabs: Unhandled exception (details below). Please report this as a bug to the developer (support@visualdesigncafe.com) if this exception keeps appearing.
    3. Bug report:
    4. {
    5.     Message: "Argument is out of range.
    6. Parameter name: index (ArgumentOutOfRangeException)"
    7.     Version: "1.2.4.35"
    8.     StackTrace: "  at System.Collections.Generic.List`1[VisualDesignCafe.Editor.Prefabs.PrefabOverrideObject].RemoveAt (Int32 index) [0x00013] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:538
    9.  at VisualDesignCafe.Editor.Prefabs.PrefabOverrides.Clean (System.Func`2 getObjectPath, System.Func`3 propertyValidation) [0x00000] in <filename unknown>:0
    10.  at VisualDesignCafe.Editor.Prefabs.NestedPrefabPostprocessor.PostprocessPrefab (System.Collections.Generic.List`1 assetGuids, VisualDesignCafe.Editor.Prefabs.Prefab prefab, Int32 depth) [0x00000] in <filename unknown>:0
    11.  at VisualDesignCafe.Editor.Prefabs.NestedPrefabPostprocessor.RegisterChildren (System.Collections.Generic.List`1 assetGuids, VisualDesignCafe.Editor.Prefabs.Prefab rootPrefab, UnityEngine.Transform child, Int32 depth, Boolean rootIsModelPrefab) [0x00000] in <filename unknown>:0
    12.  at VisualDesignCafe.Editor.Prefabs.NestedPrefabPostprocessor.PostprocessPrefab (System.Collections.Generic.List`1 assetGuids, VisualDesignCafe.Editor.Prefabs.Prefab prefab, Int32 depth) [0x00000] in <filename unknown>:0
    13.  at VisualDesignCafe.Editor.Prefabs.NestedPrefabPostprocessor.RegisterChildren (System.Collections.Generic.List`1 assetGuids, VisualDesignCafe.Editor.Prefabs.Prefab rootPrefab, UnityEngine.Transform child, Int32 depth, Boolean rootIsModelPrefab) [0x00000] in <filename unknown>:0
    14.  at VisualDesignCafe.Editor.Prefabs.NestedPrefabPostprocessor.RegisterChildren (System.Collections.Generic.List`1 assetGuids, VisualDesignCafe.Editor.Prefabs.Prefab rootPrefab, UnityEngine.Transform child, Int32 depth, Boolean rootIsModelPrefab) [0x00000] in <filename unknown>:0
    15.  at VisualDesignCafe.Editor.Prefabs.NestedPrefabPostprocessor.PostprocessPrefab (System.Collections.Generic.List`1 assetGuids, VisualDesignCafe.Editor.Prefabs.Prefab prefab, Int32 depth) [0x00000] in <filename unknown>:0
    16.  at VisualDesignCafe.Editor.Prefabs.NestedPrefabPostprocessor.OnPostprocessPrefab (UnityEngine.GameObject prefab, System.Collections.Generic.List`1 assetGuids) [0x00000] in <filename unknown>:0
    17.  at VisualDesignCafe.Editor.Prefabs.NestedPrefabPostprocessor.OnPostprocessAllAssets (System.String[] importedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromAssetPaths) [0x00000] in <filename unknown>:0 "
    18. }
    19.  
    20. UnityEngine.Debug:LogError(Object)
    21. VisualDesignCafe.Editor.Prefabs.NestedPrefabPostprocessor:OnPostprocessAllAssets(String[], String[], String[], String[])
    22. UnityEditor.DockArea:OnGUI()
    23.  
    24.  
    Context: We recenty changed one of the scripts attached to multiple prefabs involved, where it now holds lists of a custom asset type (which holds a few floats). I'm still investigating.
     
    Last edited: Nov 9, 2017
  35. BazookasZerreth

    BazookasZerreth

    Joined:
    Dec 8, 2016
    Posts:
    17
    Seems to be that the nested prefab overrides contained serialized data (a reference to a custom asset & a bitmask) that it now has trouble to remove since they were changed to lists.
     
  36. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    UPDATE
    Found it, clicking on prefab icon selects the right prefab. Thanks

    If i click on Stats-A, and then try to select original prefab by clicking on Top right Prefab [Select] button, it selects owner (Base Container) prefab :/ Please advise as i have so many variations and i dont know which belongs to which
     
    Last edited: Nov 9, 2017
  37. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    We are working on implementing support for variations so you can save a prefab as a variation, skipping the need for the additional parent. :)
     
    jGate99 likes this.
  38. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Please check your email regarding this issue. It should be fixed in the latest version that is available on the Asset Store. Please download it and give it a try.
     
    BazookasZerreth likes this.
  39. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    That'd clearly make your already winner plugin to winner of its own :)
    Any ETA? i'd rather wait for this functionality so idea of launch'd b appreciated.
     
  40. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Another issue, TMPro has Underlay style in Material Settings, how i override it? (i want to override its colour)
    Thanks
     
  41. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    The Underlay style in the material settings are part of the material asset and not the prefab, so they can't be overridden. Instead, you can create a new material with the correct settings and override the 'Shared Material' property of the TMPro component.
     
  42. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    It has been scheduled for the 1.3.0 update. There are still one or two minor updates planned with performance improvements before the 1.3.0 update, so it can take a few weeks until it is available. There is no more specific ETA at the moment, but I'll post updates and screenshots here once there is a solid prototype.
     
    jGate99 likes this.
  43. thanhle

    thanhle

    Joined:
    May 2, 2013
    Posts:
    162
    i don't know you use playmaker or not but i found big trouble with Nested Prefabs

    I use Nested Prefabs to my project use Playmaker and ( i working with Cloud Collab in unity )
    I test with easy FSM in playmaker it work fine but if use with complex FSM some time it auto change my variable in my FSM

    this error occurs infrequently but it has a big impact on the project !

    other error : if you edit fsm direct in prefab it will not apply to other ... but if you drag that object to scene then you edit and hit apply it will work !
     
  44. thanhle

    thanhle

    Joined:
    May 2, 2013
    Posts:
    162
    I uninstall Nested Prefabs in my project but it not clean !
    it have the script missing in every object in the scene
    er.jpg
    How i can clean it ?
    If i just remove Nested Prefabs not uninstall so what happen ?
     

    Attached Files:

    • er.jpg
      er.jpg
      File size:
      60.5 KB
      Views:
      718
  45. jschroyen

    jschroyen

    Joined:
    Aug 19, 2015
    Posts:
    22
    I want to update NestedPrefabs through the automatic NestedPrefabs downloader in Unity, it popped up once and I closed it at the time, but I want the updater back to use it now. How can I trigger it to open?

    Edit: Never mind, after an hour or so and a few Unity restarts it turned up again, downloaded and installed
     
    Last edited: Nov 12, 2017
  46. jschroyen

    jschroyen

    Joined:
    Aug 19, 2015
    Posts:
    22
    When I make changes to a prefab in the Project view, the changes only propagate to instances in the scene, not instances nested other prefabs in the scene or nested in other prefabs in the Project view. If I reimport the original prefab the changes will propagate as expected. Is this a bug or a limitation?
     
  47. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    If you change the prefab asset directly in the project view you have to either save the scene, save the project (File/Save Project), or reimport the prefab. This is because Unity does not save the changes to the prefab until you do one of those, and Nested Prefabs does not propagate any changes unless the prefab is saved. So it is indeed a limitation in this case.
     
  48. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    If you edit a prefab asset directly then you have to make sure to save the scene in order to apply the changes. I will look into Playmaker to see if I can reproduce the issue you are describing.

    How did you uninstall Nested Prefabs? If you remove Nested Prefabs then please make sure to explicitly choose the "Uninstall" option and not just remove the plugin files. The Uninstall option will make sure that all the components are removed properly.
     
  49. thanhle

    thanhle

    Joined:
    May 2, 2013
    Posts:
    162
    Yes i use "Uninstall" option but it work so long !
    and it take so many Ram in my computer
    I think it just remove "script missing" in the scene opened !
    it not remove all scene in the project !
    here is my task manager in my computer !

    ae.png

    So can you make a Other Plugin to remove component "script missing" ?
    i need something easy ... because my ram is limit !
     
  50. thanhle

    thanhle

    Joined:
    May 2, 2013
    Posts:
    162
    I was wrong when I used Nested Prefabs for my playmaker project !
    now i try to remove it but ,seems I'm in trouble again ....