Is there a way to figure out what prefab a GameObject is linked to at runtime?
For example: A designer places an enemy on stage, which when destroyed, spawns himself again. Except that the prefab path is hardcoded; and would be great if the script could just figure out what prefab he is linked too, and respawn.
An option could be that the editor could fill this in, when placed on stage…
Optimally you wouldn’t have the object know that at least I wouldn’t approach that way.
What I would actually do is actually have a spawner component that tracks the entity. If the entity dies, it spawns a new one in the original spawn place.
That way you can cleanly seperate the “spawner” and the actual entity in the world, which will save you lot of headache and especially gives you a reusable spawner functionality