Introduction to Tilemap in Unity

Introducing Tilemaps and what we can do with them in Unity

Objective: Speak about Unity’s Tilemaps and show what we can do with them.

Getting Started

If you have not already, create a new 2D project in Unity. Once everything is created, you should be on a screen similar to what I have here (unless you are following along in your own project).

To start, open up your Tile Palette window by going to Window -> 2D -> Tile Palette. I clipped the window at the bottom left of my screen, and you should have something similar.

Next, while hovering over the Hierarchy window, right-click and in the resulting pop-up, select 2D Object -> Tilemap. You should see a new GameObject named Grid was added to your scene and with it a child named Tilemap as well. I will be changing my Tilemap name to Ground_Tilemap.

With that setup, we can now go ahead creating our palettes and tiles.

Painting on Tiles

To get started, I will demonstrate how you can create tiles from an image. First, ensure you have an image you would like to create tiles with and set its texture type to Sprite (2D and UI). Once done, change the Sprite Mode property to Multiple. With that, apply the changes and then open the sprite editor. You should have a window similar to this

Just without the squares. To get the same look I have, hit the dropdown menu that says Slice and slice your image into a grid size that works for you. You should have a result similar to mine above. When done, you should see these created tiles equivalent to the pixel size you sliced under the original image in the Project window.

Also, be sure to have your Pixels Per Unit be equal to the cell size you used to slice your image into tiles. This can be found in the Inspector window when you have the original image selected. Next, create a new palette, through the Tile Palette window. I named mine Ground Items. You should have a result as shown below.

With the image we sliced before, drag-and-drop that into our Tile Palette window. Once loaded, you should see your image now in the Tile Palette window.

With that, we can now select tiles with the Paint Brush tool and then paint the selected tile onto our scene.

That’s all for today. Thanks for reading. In the next article, I will go over how we can animate these tilemaps.