- Home /
Is there a HideFlags.DontSave equivalent for preventing child objects from being applied to a prefab?
I have a prefab that adds GameObjects as children of itself on Start(). I want this to occur in the editor (using ExecuteInEditMode) so that I can preview the scene without actually playing the game. By using HideFlags.DontSave on the generated GameObjects, I can keep them from being saved to the scene. However, the flags appear to have no affect on Apply to Prefab. When I Apply, the GameObjects get added to the prefab. Is there any way to prevent this?
I would also like to know if this is possible. I wish to achieve essentially the same thing. I have tried also setting HideInHierarchy/HideAndDontSave HideFlags but these don't appear to prevent saving the objects to the prefab.
Up please, this issue is really a problem, is it concidered as a known bug ?
AFAI$$anonymous$$ GameObject Inspector's Apply button does a ReplacePrefab
with the ConnectToPrefab
option. ReplacePrefab is defined in unmanaged land (i.e. C++ side), so there's no chance we can see how this works internally... but it seems to me it collects the hierarchy without taking into account each object hide flags. So... I'm afraid there is no way (as of Unity 5.0.0f4) to prevent children being applied to prefab via hide flags.
This seems an consistency issue I$$anonymous$$O. $$anonymous$$aybe it's a good idea to report/discuss it with the $$anonymous$$m itself? If there's a reason this should be working the way it is, I'd like to know..
Your answer
Follow this Question
Related Questions
Instantiating a prefab in the editor is orphaning the children of the prefabs 0 Answers
Why does my prefab create a child by itself in ProjectView 0 Answers
PrefabUtility.GetPrefabObject doesn't work! 2 Answers
Breaking a prefab connection 7 Answers
Change angle of camera in prefab preview 4 Answers