[Unity] TileMap Editor

[Unity] TileMap Editor

With the LadybugRiders, we wanted to make a game with Unity using a tile-based system. Unfortunately, after some research on the Asset Store, it seemed like every TileMap editors were not free.

So I decided to make my own, using the new system of Sprites integrated since Unity 4.3.

tileeditorScene

You can download the package here. Check below for a quick tutorial.

How to use

Import the package into your project. This should create the following Scripts :
TileMapEditor.cs
Tile.cs
TileMap.cs
TileSet.cs
RowWrapper.cs

First, you’ll want to create a TileSet and some Tiles, via the ‘Assets/Create’ menu, or directly by right-clicking into yout project folders viewer :

create_tileset

Create a Tile
A Tile is basically a prefab containing a GameObject with a SpriteRenderer component and a Tile (Script)  component.
You just have to set the texture of the sprite.

tilePrefabInspector

Create a TileSet
A TileSet comes in the form of a .asset file. It just contains a list of Tile prefabs. Modify the size of the array and drag your previously created Tiles prefabs.

tilesetInspector1

Create a tilemap
Create an empty GameObject in your scene and attach a TileMap (Script) component to it.

Use the Tileset property to select the TileSet we just created.
Then use the dropdown list to choose which Tile to draw.

tilemapInspector

Once you’ve done that, go into the hierarchy and select the TIleMap GameObject. Nothing will be drawn if this GameObject is not selected!

selected_tilemap

There you are ! You can draw your tile-based map !