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
- “[Worker0] Could not generate preview image“ error when opening macOS native plugin in the Inspector with Architecture to build for set to ARM 64-bit
- [iOS] Application.absoluteURL is empty on Awake/Start when opening via deep link with Splash Screen disabled
- Crash on MemoryManager::Deallocate when rapidly calling Addressables.LoadAssetAsync
- Crash on physx::shdfnd::atomicIncrement when adjusting values on a character controller component after entering Play mode in Prefab edit mode
- [Rendering Debugger] [NewInputSystem] Debug Overlays in Play mode throws InvalidOperationException when using New Input System
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()