Procedural TileMap generation without creating gameobject per tile.

I’ve been searching all over the internet to find a efficient way to create procedural tilemap without creating a gameobject per each tile. There is none, or simply i couldn’t find it, because i really don’t know how to make a search for it. All the TileMap tutorials i found are creating tiles by creating hunderds of gameobjects. Thus the hierarchy in Unity is expanding uncontrollably.

I’m pretty sure this is not the “right” way to do it. Especially after seeing the new Unity 2D tools that supports tilemaps. Unity made it so, you can create tiles in “one” gameobject, not for each tile.

How to do it in the right way?

  • Create a mesh that contains a quad for each tile - this is a single gameobject.
  • Create a texture that has all of your tiles in a single texture.
  • Set the texture coordinates of each quad so they point to the correct area of your tile texture depending on the tile that should appear there.
  • If tiles can change you’ll need some way of updating the texture coordinates/mesh.