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
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
- UI element scale and position are wrong in project build when DRS is changed with HDR and Software Dynamic Resolution enabled
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()