- Home /
Safely deleting a child of a prefab
This is with Unity 4.1.3f3
I have a prefab with multiple child objects. One of those objects needs to be deleted. Selecting the child object, right-clicking, and selecting "Delete" does nothing.
I can "re-create" the prefab without this child object by pulling it into the scene, deleting the child object in the scene hierarchy, deleting the prefab in the project view, then re-creating the prefab by pulling it from the scene.
However, this breaks all Inspector links referencing this game object, so it's not OK.
How can I safely delete a child object of a prefab, with "safe" defined as "not breaking inspector links"?
Answer by whydoidoit · Jun 15, 2013 at 07:41 AM
Put the prefab in a scene, delete the child object, select the prefab instance in the hierarchy and click "Apply".
Note that indeed, even after you "break the prefab instance", the "Select" "Revert" "Apply" buttons DO STILL APPEAR. Strange but true.
Oh wow. That... that is terrible UI design on Unity's part. =) Deleting a child object in a scene breaks the connection to the prefab, so the natural expectation is that "apply" would no longer work, because there is no connection!
However, this worked perfectly. Thank you!
Whoa, yeah. Teeeeerrible UI. Glad to read that you can actually do this though!
Just to confirm the UI bug, and to confirm the correctness of @whydoidoit 's answer
Really bad and misleading, Unity... but thanks for the info! It works!
It has to be one of the weirdest things in Unity. I clicked "Reward User" and you should too! :)
Your answer
Follow this Question
Related Questions
Make a simple tree 1 Answer
Editor Script: Linking GameObjects to public script variables resets when playing. 1 Answer
Can I create a child gameobject on a prefab with an editor script 2 Answers
How to properly edit prefabs with child elements? 1 Answer
Need to make a reference in a prefab to itself not to the created instance 2 Answers