Search Unity

Save array of spawned object created from Custom Editor

Discussion in 'Editor & General Support' started by CoughE, Aug 8, 2016.

  1. CoughE

    CoughE

    Joined:
    Oct 26, 2015
    Posts:
    39
    Hello there,

    I have a custom editor script that spawns a 3d array of tiles and stores them. My game world will be static, i.e. the tiles will never change, as I want to run Occlusion culling on them. I have this running fine.

    The problem lies in Unity discarding the array that points to all of the tiles in the game world. I need this connection to perform distance test between tiles, something that is not possible when there are 100k+ tiles. The tiles exist in the game world still. The array is just storing plain gameObjects such as GameObject[,,] (x y and z coordinates.).

    I've done some research on here and google, but can't find anything similar or applicable.

    The classes and array are set to serialize.I tried using a SerializableObject to store the array, but realized this cannot reference the scene. Does anyone know where the problem lies?
     
  2. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,052
    Do you have it set to serializable?
     
  3. CoughE

    CoughE

    Joined:
    Oct 26, 2015
    Posts:
    39
    Yes
     
  4. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,052
    Sorry just noticed, you are using a multidimensional array, which won't serilalize. Try splitting it into two arrays, or an array of serializable classes, or using the iserializable interface to store it and reassemble.