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
- Fixing Message Loss in UMPE During Domain Reload
- The Editor freezes when ScheduleReadOnly of IJobParallelForTransform with dependency is used
- Text is truncated in the Inspector when the display scale is set to 150%
- CancellationTokenSource(<timeout>) has incorrect cancellation status when used in WebGL Player
- VFX property value names are cut off when properties with 'Arc' are viewed in the VFX Blackboard
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;