- Home /
Cannot destroy child object in prefab- Error
In the past I could delete any child object of a prefab with no issue whatsoever. Since updating I can no longer do that. Any attempt to delete a child object either through code or manually gives the error:
"Destroying a GameObject inside a Prefab instance is not allowed"
....and nothing happens. I need to delete child game objects for a procedural generation system but foer some reason cannot do this now. Is this an error with new Unity version, or what...? How can I fix this error and delete child objects of prefab? Any solution?
Thank you
Are you trying to delete the prefab itself or a copy of it created through Instantiate?
I had a slip up yesterday and that message did save me from accidentally deleting the original prefab, so it's definitely there for a reason. The message also says that you can get around that by using a different version of Destroy:
GameObject.DestroyImmediate(prefab, true);
Answer by UltraGearGames · Feb 04, 2019 at 02:52 PM
I dont really know the solution, but the new prefab workflows are the cause, im pretty sure. Solution? For now, i guess just downgrade to 2018.1 or somwhere close to that.
Your answer
Follow this Question
Related Questions
How to destroy instantiated objects. 1 Answer
Instantiating prefabs: "The object of type GameObject has been destroyed". 1 Answer
Trouble with destroying an instantiated prefab 2 Answers
Check if object is destroyed on level load, if so instantiate prefab? 1 Answer
Issues with destroying a game object 2 Answers