Search Unity

Invoking events on specific gameobjects after loading scene

Discussion in 'Scripting' started by impulse9, Dec 10, 2015.

  1. impulse9


    Sep 17, 2015
    Let's say that I enter Scene_A, on which there are two enemies, enemy_1, and enemy_2, I destroy enemy_1 and leave Scene_A. After loading Scene_B and messing around for 10 minutes I want to go back to Scene_A. Now when I enter Scene_A there are two enemies again, but I have killed enemy_1 in the past.

    How should I go about destroying this enemy? There are no unique ids in Unity (well, there is InstanceID, but it's generated per instance, so after each load of Scene_A every enemy would have different id) so I'm not sure how can I keep track of objects that should be destroyed immediately after loading new scene. I could generate them manually (bleh) but I use prefabs quite often and if I would click "Apply" button on one instance of my prefab then all ids would get overwritten.
  2. DRRosen3


    Jan 30, 2014
    impulse9 likes this.