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
- Crash on RaiseException when opening a specific project
- DownloadHandlerScript.CompleteContent is called twice when building for WebGL
- Scene view has Y coordinates of the Screen Position node flipped when some of the URP features are disabled
- Volumetric fog shader variants are missing from build when "Strict Shader Variant Matching" is disabled
- Unnecessary modifications clutter the Scene when using a RectTransform driven by a LayoutGroup in a Prefab
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;