Unity 2D Tilemap
Author and script tile-based 2D levels in Unity 6.3 LTS with the Grid/Tilemap system, the Tile
Palette, colliders, and runtime painting. Targets Unity 6.3 LTS (6000.3).
Package note: the core Tilemap (
Grid,Tilemap,Tile,TilemapCollider2D) is built in. Rule Tiles, Animated Tiles, and Tile Palette brushes live in the separate "2D Tilemap Extras" package (com.unity.2d.tilemap.extras) — install it via Package Manager before usingRuleTile.
When to use
- Use when laying out a 2D level by painting tiles, setting up a
Grid+Tilemap, adding collision to the map, using auto-tiling Rule Tiles, or generating/editing tiles from script. - Use when scenes contain a
GridwithTilemapchildren, or*.assettile/palette files.
When not to use: level design practice (pacing, blockout, layout principles) →
level-design. 3D tile/grid placement → Unity's own 3D tooling (ProBuilder / grid brushes; no dedicated skill here). The platformer character that
moves over the tiles → platformer / unity-physics.
Core workflow
- Create the grid: GameObject → 2D Object → Tilemap → Rectangular (the
Grid's Cell Layout also offers Hexagonal and Isometric for hex/iso levels). This makes aGridwith a childTilemap(+TilemapRenderer). Use one Tilemap per layer (background, ground, foreground) and set each renderer's sorting. - Open the Tile Palette (Window → 2D → Tile Palette), drag in a sliced sprite sheet to
create
Tileassets, then paint with the brush tools. - Add collision to the solid layer:
TilemapCollider2D. For one merged collider (far cheaper and gap-free), also addCompositeCollider2D(+ aRigidbody2Dset to Static) and enable Used By Composite on the tilemap collider. - Auto-tile with Rule Tiles (2D Tilemap Extras) so edges/corners pick the right sprite automatically instead of hand-placing every variant.
- Edit at runtime via script with cell coordinates (
Vector3Int):SetTile,GetTile,SetTilesBlock, converting world↔cell with theGrid/Tilemap. - Verify in Play mode: confirm collisions (Physics Debugger), sorting order, and that
RefreshAllTilesran after bulk edits.
Patterns
1. Painting tiles at runtime (cell coordinates)
2. Bulk fill a region (faster than per-cell SetTile)
3. Clearing and refreshing
Pitfalls
RuleTiletype not found — it's not built in. Install the 2D Tilemap Extras package (com.unity.2d.tilemap.extras) via Package Manager.- A collider per tile tanks performance / leaves seams — add a
CompositeCollider2Dwith a staticRigidbody2Dand Used By Composite to merge the whole layer into one smooth shape. - Confusing world and cell coordinates —
SetTile/GetTiletake aVector3Intcell, not a world position. Always convert withWorldToCell/CellToWorld. - Tiles render behind/in front of sprites unexpectedly — set each
TilemapRenderer's Sorting Layer and Order in Layer; multiple tilemaps need explicit ordering. - Rule/animated tiles don't update after script edits — refresh after writes, but prefer
the targeted
RefreshTile(cell)for a few edits;RefreshAllTiles()re-evaluates every tile on the map and stalls large levels. Reserve the full refresh for whole-map regenerations. - Painting onto the wrong layer — the active target Tilemap in the Tile Palette determines where paint lands; check the "Active Tilemap" dropdown.
References
- Primary docs: Unity Manual "Tilemaps"
(
https://docs.unity3d.com/Manual/tilemaps/work-with-tilemaps/tilemap-reference.html),ScriptReference/Tilemaps.Tilemap, and the 2D Tilemap Extras package manual (https://docs.unity3d.com/Packages/[email protected]/manual/index.html) for Rule Tiles. (@6.0is the version that ships with Unity 6.3 LTS; the old@1.6docs are for Unity 2021-era projects.)
Related skills
level-design— engine-agnostic blockout, pacing, and tile layout practice.procedural-gen— generating the tile data (noise, RNG, dungeons) you feed toSetTilesBlock.platformer/roguelike— genres that compose this skill with movement and generation.
