Best way to generate tiled ground?
Hello, I'm pretty new to Unity and I'm sure this was asked many times before but I wasn't able to find good answer.
I'm trying to do simple tile-based game but I'm not sure how should I handle ground. Map area is 258x258 tiles wide and each tile occupies one 1x1 unity unit (I don't know how to call it). Everything is flat. Ground data is saved in int array where 0 means wall, 1 is grass, 2 is water, etc. Player can freely move camera including zoom in and zoom out.
Tiles must be interactive - they will check their data and change their image. So I can't generate them at start and forget about them, they must be able to change.
My plan is: make prefab and instantiate it in a loop at correct coordinates. The question is what this prefab should use. I see two ways of doing this:
Use SpriteRenderer. The problem is - this will generate A LOT of sprites and I'm worried about performance. Especially when player will zoom out all the way and camera will show all 66564 sprites (and this is only for ground!).
Use Quads. I'm kind of afraid of using them because I don't understand materials very well. Also I will lose ability to change color/tint of individual tile, yes? In spriterenderer I can modify this but if I change material then all objects with this material will change (I'm thinking here about highlighting tile on mouseover).
How other games handle this? Games like Terraria or Starbound show thousands of individual map tiles at the same time. I heard about batching sprites but I don't really know what this mean. Any help or links to tutorials will be appriciated.
Your answer
Follow this Question
Related Questions
9-Slice Tiled sprite in 2d game ? How ? 1 Answer
How Can I Get My Sprites To Overlay My Quads?,I Can't get my sprite to oberlay the quad? 1 Answer
Synchronizing multiple sprite animations? 0 Answers
Generating Endless 2D Terrain with double lines 0 Answers
Why isn't the Tile Palette available under the Window > 2D menu? 0 Answers