Can't destroy gameObjects in Prefab Mode

I’ve made a handy editor script with some buttons which allow me to make a rope bridge by distributing hinge joints evenly between two points. It worked perfectly in editor the Scene view. But now I’m trying to use this same script in Prefab Mode and it simply won’t delete the old hingeJoint2D objects, although it clears all the lists and stuff, so it’s definitely getting called. It doesn’t result in any error or messages in the console, everything else about it works fine.

Is there a special logic or function I need to use to delete gameObjects while in Prefab Mode?

This is the line I’m using to try to destroy the gameObjects in question:

DestroyImmediate(obj);

I’d appreciate any help!

The minute after posting this I just hit the button again and it works for some reason. Didn’t change anything.

1 Like