The question is answered, right answer was accepted
Saving the position of GameObjects into array?
I'm making a 2d level editor for my game, operating on 1x1 grid. I want to be able to save the state of the map (it will have predetermined width and height) into the array, basically 0 if there's no object in this "tile", 1 if it's there. I had an idea of creating multiple colliders from script when you create a map (if i have a 25x25 map, in each tile i create a On Trigger Collider with size 1x1), and when i save the data it will check each one for the tag of the object i'm placing. Is there a simpler way of doing it?
I would use a two-dimensional Vector2-array/list, cuz' performance. All other positions in your map are just left out. Are you placing the objects by code or in the editor? if so, u are probably placing then with instantiate function. Before placing them, save their position into a list.
using System.Collections.Generic;
//...
List< Vector2 > positions;
//When placing:
GameObject tile = Instantiate( ... ) as GameObject;
positions.Add( tile.position )
Follow this Question
Related Questions
Unity Editor Panels contains weird color/fonts artifacts (screen tearing) 6 Answers
Tried everything but Intellisense doesn't work VS 2017-2019 0 Answers
Array[] of children of a child 3 Answers
Unity 2017 or 5.6 Doesn't work after install. Editor is broken. 0 Answers
save one big json string vs multi seperate json strings in playerprefs 0 Answers