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
- "Rendering Debugger" displays incorrect overdraw count when using "Unlit/Texture" shader
- Scene and Game views break when the Editor window is snapped with the Microsoft PowerToys
- Materials do not transfer texture when the "Shader" parameter is changed from "Unlit/Texture" to "Universal Render Pipeline/Unlit"
- [Linux][Vulkan] Crash when opening searchable dialog
- The "Shader error in 'AE/Leaves': "Undefined punctual shadow filter algorithm"" error appears when build completes on a specific project
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()