performance - Unity3d - Best way to save a lot of Vector3 in a collection? -


i trying save block positions in kind of collection. example, if have grid of 16*16 blocks, need save 256 block positions. use array or list right? no problem here.

but when have grid of grids, 10x10 grid of grids. need save 10x10x256 blocks. save blocks in every grid, every grid keeps track of it's own blocks. no problem here (yet).

the problem need iterate on grids check if grid has adjunctive grid. results in enormous looping times.

i wondering if there kind of way reduce this, or better.
thinking of using position of these blocks index in collection, example using multidimensional array gives lot out of bounds errors, somehow can't use that.

if understand correctly may need stored each gameobject in array of gameobject may not exception here

    gameobject[,] arrayofgameobjects = new gameobject[10, 10];            public void spawngrid ()                 {                     (int y = 0; y < 10; y++) {                         (int x = 0; x <10; x++) {                          arrayofgameobjects[x,y] = instantiate (yourprefabgameobject, new vector3 (x, y, 0),quaternion.identity)as gameobject;                             }                     }                 }      public checkadjof (gameobject gameobj)             {                  if (gameobj == null)                 {                      //do stuff if null                      //for example break, return                      }                  int x = (int)gameobj.transform.position.x;                 int y = (int)gameobj.transform.position.y;                  gameobject left,right,up,down;                        if (x < marray.getupperbound (0))                        right = arrayofgameobjects [x + 1, y] == 0);                  if (x > 0)                   left = arrayofgameobjects [x - 1, y] == 0);                   if (y < marray.getupperbound (0))                 = arrayofgameobjects [x, y + 1] == 0);                  if (y > 0)                 down = arrayofgameobjects [x, y - 1] == 0);                  // can find diagonal gameobjects                  // stuff after getting adjunctive grid/block               } 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -