Hi, I am new to Unity (but not to game programming). I’ve been trying to figure out how, using a spritesheet of fixed-size tiles, to render a 2D grid which changes at runtime.
Ideally, I would store the grid in a very large 2D array of integers from 0 to 4, for example, which correspond to each of the 5 tiles in one common spritesheet texture. In other gaming libraries (say XNA or SDL) I would normally just use one texture, and iterate through the grid, moving the rendering rect within the texture and then drawing at the appropriate position.
Spritesheet:
[0][1][2][3][4]
Grid:
[1,1,1,1,1,1,1]
[1,2,2,3,2,2,1]
…
As far as I can tell, I can’t seem to override the rendering function, so the only solution I see atm is storing a Sprite for each block. Unfortunately, I’m not trying to develop a simple RPG tilegrid, but rather tiles of very very small size, which can be destroyed at runtime. This would therefore be somewhat of a memory-expensive solution. I read something about SpriteBatching, but more about how it’s built into certain areas of Unity, and not how to use it myself.
I’m wondering if there is some common approach that is used for problems like this in Unity.
Thanks!