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
- VFX Graph Documentation dropdown button does nothing when clicked on the right side
- Required SpriteMask class (ID 331) is stripped when "Strip Engine Code" is enabled
- “Maximized serialized file backup not found” error is thrown when minimizing a window in a newly opened project
- Build stack trace contains invalid lines when building with IL2CPP using scripts with delegates containing generic types in the signature
- Entities Systems window has a “Show Full Player Loop” dropdown which does nothing when clicked after enabling “Show Full Player Loop”
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()