Search Unity

Custom window and array

Discussion in 'Scripting' started by Jungle, Jan 8, 2014.

  1. Jungle

    Jungle

    Joined:
    Apr 21, 2013
    Posts:
    13
    Hey all, so i have a custom window for a tool i'm writing which has an array of game objects that this tool can select randomly from and instantiate the object in the editor scene view before runtime, the array of game objects resets upon play which is really just a nuisance but it would be nice if it would remember the objects assigned to it. It seems to be something to do with the array because a single game object will persist through a play test but once replaced with an array of game objects it resets the moment I press play.

    Anyone have a solution to this??

    Thanks
     
  2. gfoot

    gfoot

    Joined:
    Jan 5, 2011
    Posts:
    550
    Use a ScriptableObject to wrap the array and thus save the list of GameObjects into a fully-fledged asset file - then it will remember the array state forever.