Search Unity

Only keep gameobject create on runtime while game is running

Discussion in 'Scripting' started by geoffreyc34, Nov 30, 2012.

  1. geoffreyc34

    geoffreyc34

    Joined:
    Nov 30, 2012
    Posts:
    2
    Hi there,

    I've been looking around for this but can't find an answer. I am creating gameobjects through a script at runtime, but once the script runs, all of the created game objects stay in the scene forever afterward, meaning that when I run the game again, they all get duplicated.

    What I am trying to do is for those gameobjects to only be created when the game is running, and then disappear once stopped. Is this possible?


    Thanks
     
  2. geoffreyc34

    geoffreyc34

    Joined:
    Nov 30, 2012
    Posts:
    2
    My bad, my script was also running OnDrawGizmosSelected, they do disappear if run on start only. My apologies :)