The rule tile is a huge time saver for Unity projects. They let you quickly draw tiles on the screen rather placing them block by block. So today, I’ll walk you through setting up your own Unity rule tile.
Install the Unity 2D Extras Package
The option to create a rule tile isn’t included in Unity by default. Instead, the rule tile isincluded in a separate package called “Unity 2D Extras”. If you don’t already have this package installed, you’ll need to do that first.
I’ve created a separate guide on installing Unity 2D Extras. Be sure to check that out.
Create the Rule Tile
Once you have the Unity 2D Extras package installed, you should gain the ability to create rule tiles. To do this, go to your Project panel. Right click and select:
Create -> 2D -> Tiles -> Rule Tile
If you do not see this option, it likely means you do not have the Unity 2D Extras package installed properly in this project.
I recommend doing this inside your art assets folder. Designate a new directory specifically for the rule tile if you want to keep your Unity project super organized.
Add Tiling Rules
Click on the newly created rule tile from the Project panel. This will open it in the Inspector panel. Here, you will find all of the tiling rules (currently empty).
Select a default sprite in the top option. This will appear on your tileset palette later. So make sure it is an accurate representation of the entire tileset.
Under Tiling Rules, click the + icon to add a new rule. With the new rule that was created, select the sprite this rule is to be applied to.
You’ll also see a 3×3 grid. This is where you define the actual rules. Click once to add a green arrow; twice for a red X. Green arrows means the tile must have an adjacent neighbor on that side. Red X means it must not have a neighbor. Empty cells don’t matter.
Here, I’ve added the sprites for the top row of my tilemap. First is the upper-left corner. This piece requires a adjacent tile to the right and below it. There cannot be one above or to the right. The second rule is for middle pieces. There must be a neighbor on both sides and below, but not above. And the bottom rule is for the upper-right corner. Neighbor required on the left and below, but not above or to the right.
Repeat this process for each tile in your tileset.
The arrow system is a little unusual the first time you use it. Especially for those more unusual rules (like interior corner pieces, if your tilemap has them). Just stick with it though. It’s totally worth the time to set it up right.
Add the Rule Tile to Palette
Click your Tile Palette panel to switch to it. If you do not see this panel, you can activate it by clicking Window -> 2D -> Tile Palette in the Unity menu.
In the Tile Palette panel, select the active tilemap you want to add the rule to. If you need, you can add a new palette from this panel as well.
Drag the new rule tile onto the tile palette.
Here, I’ve selected my Gameplay Palette. Then, I pulled in the rule tiles for both my ground and rocks tileset.
Once this is done, your rule tile is all set up and ready to use!
Conclusion
The rule tile system can be a little tricky to set up in Unity the first time. With rule tiles not being included in Unity by default, the package installation is probably the hardest part. But once you get that done, setting up the rule tile itself and adding the rules to it isn’t too difficult once you know how. I hope this helps!
I’m in the process of creating a template system for rule tiles. My goal is to save time on the setup and make it easier for artists to know precisely what they need to create. If this sounds like something you’d be interested in, be sure to sign up for my newsletter and check back.