Unity 4.0.0f7
void OnDestroy(){
Instantiate(prefab, position, rotation);
}
SO I have this very, very simple piece of code that instantiates a prefab (say an explosion) at a preset position/rotation when the object the behavior is applied to receives its OnDestroy message.
The problem is that this code seems to run and instantiate objects into the scene when I hit the Play button in the editor.
This error is thrown once:
This error is thrown repeatedly for every instance of the “Mistakenly” instantiated prefab that now exists in the scene AFTER playback has stopped…
Basically my OnDestroy script is leaving turds all over the scene file even after playback. They don’t seem to serialize but they’re a real hassle to clean out and something just seems wrong to me. Has anyone encountered this?