Join Jesse Freeman for an in-depth discussion in this video Setting up the project, part of Unity 5 2D: Building a Tile Map Editor.
- Now in order to start building our Tile Map Editor, we're going to need to create a new project. I'm going to call this project Tile Map Editor. We're also going to set the mode to 2D and create the project. As you can see Unity's set up to the default layout, we're going to change this for this project. Going to Window Layouts and select the 2 by 3, drag project below the hierarchy and move the inspector next to the hierarchy panel. Now, this will be a little bit easier to work with when we're doing the Tile Map Editor. We'll be able to make changes to our map in the scene and we'll be able to preview those changes real time in the game screen below.
Next, let's create the folders we'll need for our project. We'll start with an artwork folder to hold our sprites, next we're going to create a scenes folder to hold our test scene, then we'll need a scripts folder and finally we're going to need a special folder called Editor. The Editor allows you to put code inside of this folder that will only work inside of the Unity IDE, this way when we extend the IDE to build our Tile Map Editor we don't have to worry about that code ending up in our final game.
Next, we're going to want to drag our sprite sheet into the artwork folder. Bring the dorm tiles into the artwork folder, select the sprite, and now let's make some modifications to it. First, we're going to set the sprite mode to multiple, we're going to set the filter mode to point, and if you scroll down we'll set the format to true color and hit apply. Next we'll need to cut out the individual sprites from the sprite sheet. Open up the sprite editor and go to slice.
From here we're going to do a grid by cell size and we'll make this 16 by 16 and hit slice. As you can see, we now have sprites for each of the tiles. Hit apply and close out the window. At this point the project is set up, let's save the scene into the scenes folder, we're going to call it TileMapEditorStaging. And now, select your scenes folder and hit save. And now we have everything set up so we can start building our Tile Map Editor.
- Adding custom dropdown menus to Unity
- Building a custom inspector
- Creating a texture picker
- Drawing the tile map grid
- Creating a tile picker
- Scaling a Texture2D
- Creating a tile brush
- Moving the tile brush
- Erasing and clearing tiles