Search Issue Tracker
By Design
Votes
0
Found in
2019.3
2019.3.2f1
2020.1
2020.2
Issue ID
1223430
Regression
Yes
Opening a nested Prefab consisting of two Prefabs results in a corrupted and broken Prefab which becomes a Prefab variant
Reproduction steps:
1. Open the user's attacjed project "PrefabDebugging.zip"
2. In the Hierarchy window create a new empty GameObject
3. Under the "Assets/Prefabs" folder add the "ENT_dwarven_axe_lvl_01_001_worldspace" and "ENT_dwarven_axe_lvl_02_001_worldspace" Prefabs as children
4. Save the empty GameObject as a Prefab in the Project window
5. In the Hierarchy window open "GameObject" GameObject in Prefab Mode
Expected result: Prefab Scene View is opened normally without any errors in the console
Actual result: Prefab is broken and becomes a Prefab variant of one of the children
Reproduces on: 2019.3.4f1, 2020.1.0a26, 2020.2.0a1
Could not reproduce on 2018.4 and 2017.4 due to errors in the Console window
-Does not reproduce on a fresh project
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Some UXML Template Asset foldouts appear enabled when all fields inside are disabled
- URP Terrain Demo crash on burst_signal_handler after Generating lighting
- Project window button icons are poorly visible and their shades differ in Light theme
- GC.Alloc called by HDRenderPipeline.LensFlareMergeOcclusionDataDrivenPass() when playing the default HDRP Sample Template project
- Automatic LOD fails and SRP Batcher incompatibility occurs when using spline-based quad-topology meshes
Resolution Note:
The problem comes from the user script: BaseGameObject.cs line 254.in OnEnable(): here 'PrefabUtility.SaveAsPrefabAsset(this.gameObject, stage.prefabAssetPath)' is called, where 'this.gameObject' is a child of the prefab opened in Prefab Mode. Outcommenting this line fixes the issue.
In general it is not a good idea to save a Prefab from OnEnable as this is called while loading the PrefabStage(). It is recommended to delay any saving and also make sure to check that the correct root GameObject is used as input to PrefabUtility.SaveAsPrefabAsset()