First goal: Rendering a map – Map indices
Continuing from my last post, I had 3 goals for getting a map to render. Now I’m on #2:
Some sort of array that will tell the game what tiles to place where on a grid. Since my maps have to be generated at runtime, this will need to be an external file.
In Tiled, you can give each tile a custom property. If you call that property “name”, then when you export to a CSV, it will use that name value rather than an ID. When Unity reads the file, I can tell it to read those values into an array. That array can then tell the code to make a map with tiles corresponding to those values.
So how should I name each tile? I could just use straight numbers, but those will certainly range in how many digits they contain. This is a potential problem for several reasons that I don’t want to get into here. Suffice it to say, I want all the tile IDs (and in fact all game item IDs) to be a limited number of digits. If I use 0-9 and A-Z that gives 36 options per digit. a 2 digit ID would then be 36×36 = 1296 base items for the game. That seems pretty good. If I add a 3rd digit for variants (like 2 different doors that need 2 different keys) that gives me quite a lot of variants, especially if I don’t limit myself to just alphanumerics, but also include other supported Unicode characters.
From here, it was a pretty short jump to making a map in Tiled.

Now I just have to get Unity to create the same thing from just a CSV and some art assets!


