Destroying Instantiated Prefabs From A Different GameObject

I’m new to unity but I can’t find a solution to this on any forums that help me.
In a script in my Controller GameObject, I want to destroy all instantiated prefab clones, but everything I could find was not permitted to avoid data loss. When I changed Destroy() to DestroyImmediate() to make the game run, it just ruined all my prefabs when I tried it out, and now they are completely empty and impossible to edit/delete.

If using DestroyImmediate() ruined your prefabs then you called DestroyImmediate on the prefab itself and not the instantiated gameObject. For example if you had this :

public GameObject MyPrefab;

which is a prefab dragged onto the inspector then called :


it would indeed do just that. What you need to do is this :

GameObject obj = Instantiate(MyPrefab);
Destroy(obj); //note obj NOT MyPrefab