Easy way to track and destroy prefabs?

I’ve been looking everywhere to find a way to track prefabs.

I found this:

 thePrefab.GetInstanceID() ;

But then, to go backwards and access an object via its ID, the only thing I found is:


But it seems to be only through the EditorUtility.
Can I use something similar from a script?

I will have a maximum of 50 prefabs and they will be deleted in an unpredictable order.
I’ve been advised to use lists, but what am I gonna store in these lists if it’s not the InstanceID? The gameObject? (modifying thePrefab.tag or thePrefab.name seems to be inefficient because I would have to use Find() )

You can store your prefabs in a dictionary.

Dictionary, where the key is the prefab name (gameObject.name). With this, you can access the prefab via its name.