0
0
Unityframework~8 mins

Tilemap painting in Unity - Performance & Optimization

Choose your learning style9 modes available
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.
Updating many tiles individually every frame
Unity
var tileChanges = new List<TileChange>(); foreach (var tile in tilesToUpdate) { tileChanges.Add(new TileChange(tile.position, tile.newTile)); } tilemap.SetTiles(tileChanges);
Batching tile updates reduces draw calls and GPU uploads to a single operation.
📈 Performance Gainsingle draw call and GPU upload per batch, reducing frame rendering time
Updating many tiles individually every frame
Unity
foreach (var tile in tilesToUpdate) { tilemap.SetTile(tile.position, tile.newTile); }
This triggers multiple separate draw calls and reuploads to the GPU, causing slow rendering.
📉 Performance Costtriggers N draw calls and GPU uploads per frame, where N is number of tiles updated
Performance Comparison
PatternDOM OperationsReflowsPaint CostVerdict
Individual tile updates per frameMany tile set callsN reflows (conceptual redraws)High GPU paint cost[X] Bad
Batch tile updatesSingle batch set call1 reflowLow GPU paint cost[OK] Good
Rendering Pipeline
Tilemap painting updates the GPU texture atlas and triggers the GPU to redraw the affected tiles on screen.
Layout
Paint
Composite
⚠️ BottleneckPaint stage is most expensive due to GPU texture updates and draw calls.
Optimization Tips
1Batch tile updates to minimize GPU draw calls.
2Avoid updating tiles every frame unless necessary.
3Use Unity Profiler to monitor draw calls and GPU usage.
Performance Quiz - 3 Questions
Test your performance knowledge
What is the main performance cost when updating many tiles individually every frame?
AMultiple GPU draw calls and texture uploads
BIncreased CPU memory usage
CSlower physics calculations
DLonger script compilation time
DevTools: Unity Profiler
How to check: Open Unity Profiler, record while updating tiles, check Rendering and GPU usage sections.
What to look for: Look for high draw call counts and GPU upload spikes indicating inefficient tile updates.