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
- [iOS] Back Triple Camera is not focusing manually and automatically
- Mouse inputs cannot be inputted when searching the Shortcuts Menu by type "Shortcut"
- "Debug Assertion Failed!" error when launching Windows Dedicated Server Player with Script Debugging enabled
- [Cinematic Studio][3D HDRP] Shader warnings thrown in the Console window when creating a new project with Cinematic Studio template
- Autoplay is triggered on Audio Assets when changing Asset Bundle tags
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;