Unity Rule Tile from a 47 or 16 Tileset — No Rules by Hand
Instead of chopping the sheet and clicking 47 neighbour rules, drop it here: the layout is recognised, and the Unity bundle's editor script slices the sprites (Point, uncompressed) and builds the Rule Tile from the bits.
A Rule Tile (2D Tilemap Extras package) is a list of tiling rules: each rule is a 3 × 3 grid where every neighbour is ignored, must be this Rule Tile (green arrow) or must not be (red cross). Unity checks the rules from the top and paints the first match, or the Default Sprite when none matches. A blob tileset means 47 rules by hand. Nerulio writes the rules from the tile bits and ships an editor script that slices the PNG and creates one RuleTile per terrain; checked in Unity 6000.5.3f1 with Tilemap Extras 8.0.3. Corner and dual-grid sets are not exported to Unity.

- Unity 6 Rule TileVerified· Unity 6000.5.3f1 + 2D Tilemap Extras 8.0.3
- Godot 4 TileSetVerified· Godot 4.7.2
- TiledVerified· Tiled 1.12.2
- LDtkPartly verified· LDtk 1.5.3 schema + loader
How a Rule Tile chooses a sprite
The Tilemap Extras manual describes the parts: Default Sprite (painted when no rule matches), Default Collider, and a list of Tiling Rules, each with a rule grid, a sprite and an output (Single, Random or Animation). In the rule grid a cell can be empty (ignore that neighbour), a green arrow (the neighbour must be this Rule Tile) or a red cross (it must not be). "Unity checks each rule in turn, starting at the top."
Because the first match wins, order matters: a loose rule above a strict one hides it. Nerulio sorts the rules by how many neighbours they check, most first, and leaves a corner empty when a side next to it is open (it cannot change the picture), so a blob rule checks between 4 and 8 neighbours. Unity's grid has y pointing up, so the northern neighbour is (0, 1).
A Rule Tile paints on the cell it sits in and looks at the cells around it. A dual-grid tile belongs to the point between four cells, which a Rule Tile cannot express, so corner sets are left out of the Unity export. Several terrains in one sheet become separate Rule Tiles; each treats the others as "not this", so they meet without transition tiles.
- Rule Tile
- A tile asset from 2D Tilemap Extras that picks its sprite from neighbouring tiles.
- Default Sprite
- What Unity paints when no tiling rule matches — for a Nerulio export, the full interior tile.
- This / Not This
- Green arrow: the neighbour is this Rule Tile. Red cross: it is not. Empty: ignored.
- Rule order
- Rules are tested from the top; the first match paints.
Example: the rule for one blob tile
tile mask 31: N, NE, E, SE, S connected, W open (Unity grid, y up)
. ✓ ✓ . = ignored (corners behind the open west side)
✕ C ✓ ✓ = This (green arrow)
. ✓ ✓ ✕ = Not This (red cross)
JSON neighbours [[0,1,1],[1,1,1],[1,0,1],[1,-1,1],[0,-1,1],[-1,0,2]] (dx, dy, 1 This / 2 NotThis)
blob-47 → 47 rules, most checks first; Default Sprite = the full tile
16-side set → 16 rules, 4 side checks eachSprites are named after their column and row in the sheet (the mask-31 tile above is tile_4_1 in a cr31 8 × 6 sheet), and their rectangles are measured from the bottom-left of the texture, as Unity counts.
What it does
- Blob-47 and side-16 sets; the rules come from the recognised or painted terrain bits.
- Editor/NerulioRuleTileImporter.cs builds one RuleTile per terrain with 2D Tilemap Extras.
- Checked in Unity 6000.5.3f1 + Tilemap Extras 8.0.3: a painted Tilemap shows the predicted sprite in every cell, sprite rects and pixels exact.
- Where a combination is missing, Unity draws the Rule Tile's default sprite — the Studio's test map shows that too.
How to do it
- Drop the tileset and apply its layout.
- Read the Check panel; fill any missing combinations.
- Export for Unity 6.
- Copy the bundle into Assets/ (the .cs into an Editor folder), select the JSON and run Tools › Nerulio › Build Rule Tiles.
Files you get
| File | What it is for |
|---|---|
nerulio-ruletile.json | Sprite rectangles, pixels per unit (= tile width) and per terrain the default sprite and the ordered rules. |
Editor/NerulioRuleTileImporter.cs | Adds Tools › Nerulio › Build Rule Tiles: sets the PNG to Sprite (Multiple), Point, no mipmaps, uncompressed; slices it; writes one RuleTile per terrain. |
cave.png | The tileset image. |
README.txt | These steps. |
Terrain.asset | Written by Unity when the script runs, next to the JSON; named after the terrain ("Terrain" unless you renamed it). |
Build the Rule Tiles in Unity 6 and paint
- Install 2D Tilemap Extras if the project lacks it: Window › Package Manager › Unity Registry › 2D Tilemap Extras › Install.
- Copy the PNG and
nerulio-ruletile.jsoninto one folder underAssets/, andNerulioRuleTileImporter.csinto any folder namedEditor. - Select the JSON in the Project window and run Tools › Nerulio › Build Rule Tiles. The Console reports
Nerulio: wrote 1 RuleTile(s)and the.assetappears next to the JSON. - Create a tilemap: in the Hierarchy, right-click › 2D Object › Tilemap › Rectangular.
- Open Window › 2D › Tile Palette, drag the RuleTile asset into a palette, select it and paint with the Paint with Active Brush tool.
- For collision, set Default Collider (and each rule's Collider) to Grid in the Rule Tile inspector — the script writes None — and add a Tilemap Collider 2D to the tilemap.
Check the result
- The RuleTile inspector shows 47 tiling rules for a blob set (16 for a side set), and the Default Sprite is the full interior tile.
- Paint a 3 × 3 block and a lone cell: 9 different sprites and the isolated sprite. Where the full tile shows up on an edge, that combination is missing from the sheet.
- Sprites stay crisp at any zoom, because the script imports the PNG with Point filtering and no compression.
Troubleshooting
| Symptom | Likely cause | How to check | Fix |
|---|---|---|---|
| There is no Tools › Nerulio menu | The script is not in an Editor folder, or it does not compile because 2D Tilemap Extras or the 2D Sprite package is missing | Console: compile errors naming RuleTile or SpriteDataProviderFactories | Install both packages and move the script into an Editor folder |
Nerulio: select nerulio-ruletile.json first. | Something other than the JSON is selected | Project window selection | Select the JSON and run the menu again |
| Exception: the PNG "is not in the project" | The PNG is not next to the JSON or was renamed | image in the JSON vs the file name | Put the PNG beside the JSON under its exported name |
| The full tile appears on edges or corners | The sheet lacks that combination, so Unity paints the Default Sprite | Studio Check panel: missing combinations | Draw or generate the missing tiles and export again |
| Two terrains meet with a hard edge | Each terrain is its own RuleTile and sees the other as "not this" | Two .asset files after the build | Use one terrain per tilemap, or Godot / Tiled when you need transitions |
No unity folder in the ZIP | The set is a corner / dual-grid set; NOTES.txt says it was skipped | Match mode in the Studio: corners | Use Godot or Tiled for dual-grid sets |
| The player falls through the tilemap | Collider None on the RuleTile, or no Tilemap Collider 2D | RuleTile inspector: Default Collider | Set Grid (or Sprite) and add a Tilemap Collider 2D |
Other ways to do it
| Option | When it is the better choice |
|---|---|
| Build the rules by hand in the Rule Tile inspector | Few tiles, or rules the export does not write: Extend Neighbor (beyond 3 × 3), Random or Animation outputs. |
| Rule Override Tile (Create › 2D › Tiles › Rule Override Tile) | A second tileset drawn in the same layout: reuse the generated rules and swap only the sprites. |
| Godot terrains or a Tiled Wang set | You need dual-grid sets or transitions between terrains: Godot 4 or Tiled. |
Engine exports and how each was checked
"Verified" means the exported files were loaded by the real engine or tool on real CC0 assets and the result was compared with the source. Anything that was not loaded is labelled as such.
| Target | Files | Check |
|---|---|---|
| Godot 4 TileSet | PNG · nerulio-tileset.json · nerulio_tileset_import.gd | Verified Godot 4.7.2The included import script builds the TileSet with terrain peering bits; a map painted with set_cells_terrain_connect equals the Studio preview in every cell on 9 corpus sheets. |
| Tiled | .tsx Wang set · sample.tmx | Verified Tiled 1.12.2Tiled's own readers load every Wang ID as written and the sample map renders pixel-exact. The terrain brush itself was not driven. |
| Unity 6 Rule Tile | nerulio-ruletile.json · Editor/NerulioRuleTileImporter.cs | Verified Unity 6000.5.3f1 + 2D Tilemap Extras 8.0.3Blob and side sets: a painted Tilemap shows the predicted sprite in every cell. Corner / dual-grid sets are not exported to Unity. |
| LDtk | .ldtk (1.5.3) · rules · sample level | Partly verified LDtk 1.5.3 schema + loaderAccepted by the LDtk JSON schema and its official loader, and the rules re-run to the exported tiles; not opened in the LDtk app. |
Evidence
Layouts identified from the pixels alone on the tile corpus: 4 blob-47 templates and 2 Wang templates with high confidence, a real 64 px cave tileset with medium confidence — every tile's bits right. Godot 4.7.2 painted every test cell exactly as the Studio predicted (485/485 per blob set, 251/251 on a 4-terrain dual-grid pack); Tiled 1.12.2 read every Wang ID back; Unity 6000.5 matched on every painted cell of the blob and side sets.
Limits
- Corner / dual-grid sets are not exported to Unity.
- Several terrains become separate RuleTiles with no transitions between them.
- No collision shapes: the RuleTiles are written with Collider None; Nerulio's traced polygons go to Godot only.
- Tiled's terrain brush, the LDtk app and Godot's editor painter were not driven; the checks use the engines' readers and set_cells_terrain_connect.
- Unity gets blob and side sets only; several terrains become several Rule Tiles with no transitions between them.
- Isometric and hex tiles, animated tiles, occlusion and navigation layers are out of scope.
- Suggesting bits without a known layout needs a reference "full" tile; on side-only path templates the guess can fail until you select it.
Versions and sources
Checked in Unity 6000.5.3f1 (batch mode) with 2D Tilemap Extras 8.0.3: the shipped script built the RuleTiles, and a painted Tilemap returned the sprite the Studio predicts in every cell on 10 corpus sets, with exact sprite rectangles and pixels. Swapping two sprites in the rule JSON makes the check fail. Unity menu paths above follow the Unity 6 manual and the Tilemap Extras 8.0.3 documentation.
Official documentation used
Questions
Does it need Unity's 2D Tilemap Extras?
Yes, Rule Tiles come from that package (checked with 8.0.3).
Several terrains in one sheet?
Each terrain becomes its own Rule Tile; Unity draws no transitions between them.
Is it free, and do I need an account?
Everything on these pages is free and works without an account. There is no watermark and no export that is held back.
Are my sprites uploaded?
No. The Studio decodes, packs and exports in this browser tab. Projects are autosaved in the browser (IndexedDB) and can be saved as a .nerulio file.
Does it need Aseprite or an engine plugin installed?
No. .aseprite files are read and written in the browser, and each engine bundle carries what that engine needs (for Godot, the import settings and scene; for Unity and the Godot TileSet, a small editor script).