I am trying to create a multidimensional array of lists that stores what is on a specific tile on my grid
basically the end goal is to get here
item = map_data.mapdata[x, y];
from what i can gather from other forms posts it should look like this
public class mapdata
{
- public List[,] map_Data;*
- public mapdata(int sizex, int sizey)*
- {*
-
map_Data = new List<int>[sizex, sizey];*
- }*
}
public mapdata map_data = new mapdata(size_x,size_y);
public DTileMap(int size_x, int size_y)
{
-
for(int x=0;x<size_x;x++) {*
-
for(int y=0;y<size_y;y++) {*
-
map_data.map_Data[x,y].Add(3);*
-
}*
-
}*
}
but it tells me that
NullReferenceException: Object reference not set to an instance of an object
DTileMap…ctor (Int32 size_x, Int32 size_y) (at Assets/TileMap_D/DTileMap.cs:107)