This guide will be periodically updated to support the new, old or frustrated users of Unity Tilemaps.
Current Unity Version used : 2020.3.23f1
Download the 2D Tilemap Editor package via the Package Manager [Unity Docs](in Unitys top menu: Window > Package Manager)
Unity does offer presets that automatically install the Tilemap package when creating a new Project.
Congratulations! You have unlocked the following features:
- Tile Palette [Unity Docs](in Unity’s top menu: Window > 2D > Tile Palette)
- Grid [Unity Docs]
- Rectangular (default)
- Hexagonal
- Isometric
- Tilemap [Unity Docs] (in Unity’s top menu: GameObject > 2D Object > Tilemap)
- Rectangular
- Hexagonal Point Top [Unity Docs]
- Hexagonal Flat Top [Unity Docs]
- Isometric
- Isomentric Z as Y
- 2D Extras (Optional : in Unity’s top menu: Window > Package Manager > 2D Tilemap Editor > Samples)
- Scriptable Brushes [Unity Docs]
- GameObject Brush [Unity Docs]
- Group Brush [Unity Docs]
- Line Brush [Unity Docs]
- Random Brush [Unity Docs]
- Scriptable Tiles [Unity Docs]
- Rule Tile [Unity Docs]
- Animated Tile [Unity Docs]
- Rule Override Tile [Unity Docs]
- Scriptable Brushes [Unity Docs]
This guide is essentially split into three competency levels to better cater to learning levels. (Beginner, Intermediate and Advanced)Uni
All right, so you have no idea what you are doing with Tilemaps or are just getting started.
It's time to learn the ABCs of the Unity Tilemap package.
Recommended things to do before you continue:
- It's recommended that you create a "Sprites" Folder within your Assets folder.
- When importing Sprites/Tilesets, it's a good idea to follow the standard 8x8, 16x16, 32x32, Etc texture sizes (Makes life a lot easier)
Before we start to use the Tilemap Palette, we need to make sure that we have our sprites imported and set up for tile creation.
A single sprite indicates an image file that has been created solely for one Sprite.
The steps are as follows to set it them up correctly
- Import/Drag your chosen Sprites into your Assets/Sprites folder.
- Using Shift+LMB (or Ctrl+LMB if you like to cry), select all sprites within the folder.
- In your Inspector do the following:
- Set Texture Type to Sprite (2D and UI). (Cause its going to be a sprite, duh)
- Set Sprite Mode to Single (if it wasn't already)
- Set Pixels Per Unit to your texture size (E.g 8(8x8), 16(16x16), 32(32x32), etc)
- Set Filter Mode to Point
- Set Max Size to your texture size (E.g 8(8x8), 16(16x16), 32(32x32), etc)
- Click Apply in the inspector
Sprite Tilesets indicates an image file that holds many textures that separate into many different sprites. (It's a tileset full of textures.)
The steps are as follows to set it them up correctly
- Import/Drag your chosen tilesets into your Assets/Sprites folder.
- Using Shift+LMB (or Ctrl+LMB if you like to cry), select all tilesets within the folder.
- In your Inspector do the following:
- Set Texture Type to Sprite (2D and UI). (Cause it's going to be a sprite, duh)
- Set Sprite Mode to Multiple
- Set Pixels Per Unit to your texture size (8(8x8), 16(16x16), 32(32x32), Etc)
- Set Filter Mode to Point
- Click the Sprite Editor Button and do the following:
- Click the Top Menu's Slice
- Set Type to Grid By Cell Size (Leave it at Automatic at your peril)
- Set Pixel Size to your texture size (E.g 8(8x8), 16(16x16), 32(32x32), etc)
- Click the Slice Menu's Slice
- Select tiles individually and rename them to whatever you want
- Click Apply
- Close the Sprite Editor
- Loop step 4 until every tileset has been sliced and prepared for use.
- Click Apply in the inspector
Your tile sprites are now ready for the Tilemap Palette.
The Tilemap Palette essentially makes you an artist so let's make sure you understand it.
The Palette Toolkit is pretty straightforward with seven different tool options that are the following:
- Select Tool (S) [Unity Docs] - Used to inspect tile properties.
- Move Tool (M) [Unity Docs] - Used to move selected tile/s to another tilemap position.
- Paintbrush Tool (B) [Unity Docs] - Used to both select & paint palette tiles.
Useful tips:
- You can rotate the selected tile clockwise by pressing [ [ ].
- You can rotate the selected tile counter-clockwise by pressing [ ] ].
- You can flip the selected tile along its x-axis by pressing [Shift + [ ].
- You can flip the selected tile along its y-axis by pressing [Shift + ] ].
- Box Fill Tool (U) [Unity Docs] - Used to both select & paint palette tiles in a rectangular area.
- Picker Tool (I)[Unity Docs] - Used to select either palette or tilemap tiles before automatically changing to the Paintbrush tool.
- Eraser Tool (D)[Unity Docs] - Used to erase tiles, the area of which you can adjust within the Tilemap Palette by using the Eraser Tool to hold and drag to the desired size. (Warning! Make sure Edit is disabled if working on a Tilemap.)
- Flood Fill Tool (G)[Unity Docs] - This is used to either fill empty tile cells of identical tiles with a selected tile.
Ignore the Active Brush in the bottom section. (This is to be explained later in the Advanced (Scriptable Brushes) Section).
TBC
TBC
TBC
TBC
It's IMPORTANT that you check that you are working on the correct tilemap at all times lest you suffer from the same frustration I've felt while working on projects.
You can check that you are working on the correct tilemap by checking the Active Tilemap that's located in the Tilemap Palette window, just below the Palette's tools.
Another IMPORTANT tip to keep in mind is that you should use the Focus On feature when working on multiple tilemaps as it helps to avoid confusion and clutter.
You can do this by using the following steps:
- Select the Tilemap you wish to work on by either using the Active Tilemap dropdown or from the Hierarchy window.
- Select Tilemap on the Focus On the dropdown menu, located bottom right of the Scene View
You have some knowledge of how to use Tilemaps or like to take risks. Let's help you take it up a notch.
Recommended things to do before you continue:
- Create a "Resources" folder and place the "Sprites" folder within it
TBC
TBC
TBC
Save/Load Unity Tilemaps with JSON!
This makes use of Odin Serializer (https://github.com/TeamSirenix/odin-serializer)
Open SerializationDemo in Unity Editor to test.
TBC
This allows you to make create/modify Tilemaps as you wish and not worry about how Field of View will be affected.
This uses the ShadowCast algorithm provided by Adam Milazzo (http://www.adammil.net/blog/v125_Roguelike_Vision_Algorithms.html#shadowcode)
Open FieldOfViewDemo in Unity Editor to test.
TBC
This allows you to paint/erase tiles on Tilemaps during runtime.
Open LevelEditorDemo in Unity Editor to test.
You are an absolute whiz or feel that you are ready to have some fun. (or at least cry from frustration)
TBC
TBC