Performance: Tilemap painting
MEDIUM IMPACT
Tilemap painting affects rendering speed and frame rate by controlling how many tiles are drawn and how often the GPU updates the screen.
var tileChanges = new List<TileChange>(); foreach (var tile in tilesToUpdate) { tileChanges.Add(new TileChange(tile.position, tile.newTile)); } tilemap.SetTiles(tileChanges);foreach (var tile in tilesToUpdate) { tilemap.SetTile(tile.position, tile.newTile); }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Individual tile updates per frame | Many tile set calls | N reflows (conceptual redraws) | High GPU paint cost | [X] Bad |
| Batch tile updates | Single batch set call | 1 reflow | Low GPU paint cost | [OK] Good |