Map Editor of 2D games- Game Dev Series 98
Objective: quick introduction of Tilemap.
Tilemap is a 2D environment tool of Unity. It’s used to draw almost everything you need in your 2D game. The base of Tilemap is tile, which is bunch of sprites with basic scale of environment, and Unity can use these sprites template to draw your unique 2D environment.
In this article, you will learn how to use Tilemap in Unity and import your own sprites as tile.
The UI of Tilemap
To start using a Tilemap, you need to add a Tilemap into scene. Add a 2D Object> Tilemap in Hierarchy.
Your scene view should now full with grid. Then we need to open the Tile Palette tab. Go to Window drop down menu> 2D> Tile Palette.
This is where you can select the tile you want and paint it to game scene.
Now we are ready to import our tiles.
Turn the sprite into tiles
Unity can do lots of adjust to a sprite. To create new tiles, let’s select a sprite in Project tab.
Change the texture type to sprite. Then select Multiple inside Sprite Mode.
The pixels per Unit should be 128 according to the setting of sprite we choose. Change it and click Sprite Editor, if the system notice you to apply, apply it.
Inside the sprite editor, first we need to do is to slice the sprite into tiles. Select Slice on the top and select the proper pixel size. To this sprite, it would be 128x128. And also select Grid By Cell Size in Type. After these, click Slice.
You would see the sprite has been cut as grid. Click apply then we can drag this sprite into Tile Palette.
When drag it into Tile Palette, it would ask you to choose a saving location. Once done, you got tiles that can draw as environment.
Tilemap as layer
When drawing a 2D game environment, usually you will need to create multiple layers of game world. For example, you might not want to mix your foreground and background into one Tilemap. Separate these elements would be easier to adjust later.
When create a new Tilemap, you can choose their order in layer to make them look further of closer to camera.
Separate all the Tilemap and you will be easy when drawing your game scene.