How To Import And Slice Tilemaps In Unity
This article is continuing off of my previous one which can be found by clicking this link :
Unity can easily import a tilemap, slice it up, and equip it to be used with a variety of modular tools. This will allow you to quickly put your levels together and customize them with ease.
To get started you will need a “Tilemap” of your own. This is just a set of individual terrain sprites. You can make your own, download one off of an online asset store, or whatever. For this example, I am just going to grab one off of google.
For best practice, the individual tiles should all be based on the same template shape/size and should be evenly spaced. You must also keep in mind the pixel dimensions to be used later.
To “import” your tilemap, just drag and drop it into your project menu. My tilemap is saved as a “.png” file. But Unity is compatible with a number of different graphic/file types.
Once you have your tilemap imported, you’ll need to make sure to adjust the settings for the tilemap sprite.
Change the “Sprite Mode” to “Multiple” since this tilemap sprite contains multiple individual tile sprites.
Then set the “Pixels Per Unit” to whatever the height/width of your tiles is. Since tiles are square you should have something like (32x32) or (64x64) etc. So since my tiles are 128x128 I will set my “Pixels Per Unit” to “128".
Next, we will need to “Slice” up the tilemap into individual tile sprites. This is easy to do but is even easier to do well if you know the exact pixel dimensions of your individual tiles.
Click on the “Sprite Editor” button to open up the “Sprite Editor” window.
Then select “Slice” from drop-down menu at the top and change the type to “Grid By Cell Size”.
Next enter the Pixel Size of the individual tiles on your tilemap.
You may have to adjust the offset if your tilemap does not spread the width of the image.
Then hit “Slice” and you're done.
Now if you look at your tilemap sprite in the project window you should see that it has all the individual tiles inside of it as separate tile sprites!
Now you have all of your individual tile sprites ready to be implemented into your “Tile Pallete”. Just check out my next article to find out how!