Search Issue Tracker
By Design
Votes
4
Found in
2018.2.21f1
2018.3.11f1
Issue ID
1145961
Regression
No
Nested Prefabs hideflags are not applied when Prefab is saved
How to reproduce:
1. Open the attached 'PrefabDontSaveInEditorBug.zip' project
2. Go to the Project tab -> "Scenes" and open "SampleScene" scene
3. Go to the Hierarchy tab, select 'PrefabCreator' object and click on the 'Create' button in the Inspector tab
4. Expand 'ParentPrefab' and observe 'Prefab' object. Notice the "DontSaveInEditor" checkbox is marked
5. Go to Project tab -> "Prefabs" folder and double-click on "Prefab" asset
6. Modify prefab (ex. change transform position) and make sure 'Auto-Save' is on
7. Come back to the "SampleScene" scene "Prefab" instance and observe "DontSaveInEditor" checkbox
Expected result: Checkbox is marked
Actual result: Checkbox is unmarked
Reproducible: 2018.3.13f1, 2019.1.0f2, 2019.2.0a12, 2018.2.21f1 (a122f5dc316d)
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:
This is by design.
Prefab instance objects do not own their hideflags. The hideflags are controlled by the underlying PrefabInstance object, so every time the prefab is merged the hideflags from the PrefabInstance object is propagated to the instantiated objects.
To achieve the result the user wants, the user should change from this:
GameObject obj = (GameObject)PrefabUtility.InstantiatePrefab(t.Prefab);
obj.transform.SetParent(t.Parent, false);
obj.hideFlags = HideFlags.DontSaveInEditor;
to:
GameObject obj = (GameObject)PrefabUtility.InstantiatePrefab(t.Prefab);
obj.transform.SetParent(t.Parent, false);
PrefabUtility.GetPrefabInstanceHandle(obj).hideFlags = HideFlags.DontSaveInEditor;