Before you begin

Make sure you have the plugin in your Unity Project and make sure you have some textures to work with it.

Importing assets

First of all you need some textures to use. In the package there is a few example textures included that can serve the purpose for this tutorial. If you have any other tileset maps you want to use, import them into Unity. To maintain the NES/SNES feel of texture, make sure youset their sampling method to Point Sampling. (This is by no means a requirement.) Lastly make sure that the texture type is set to Sprite. If its set to Texture it can sometime leads to weird glitches and sampling problems causing the tileset to not tile properly.

Set up the tile set

Once textures are included we need to create a TileSet. This can be done from the Assets folder's context menu. Create the folder you want to put it (for example /Assets/Data/TileSets), right click and select Create->Bona Tile Editor->Tileset. Name it something appropriate like MyFirstTileSet.

Now we need layers for the tile set. The layers can be of different types.

  • Base layer
    Will always be rendered furthest away from the camera. As the name suggest, serves as the underlying base.
  • Overlay
    Will lay over the base layer. The overlays are ordered, and will be rendered in the order the lie in your layers list.
  • On top overlay
    The same as overlays except these lies closer to the camera. The point you are supposed to put any other game objects(like characters) between these layers so the overlays are rendered beneath other game objects and on top overlays are rendered on top of them.
Each tileset requires exactly one base layer, but are allowed to have as many overlays and ontop overlays as you wish including none. In this tutorial we will use one base layer and one overlay.

Select your newly created TileSet and press Add Layer. Give it an appropriate name, like "Base" or "BaseLayer". Make sure the layer type is set to Base Layer. The width and height settings are used to tell how many images there are in the texture and is used when it's sliced to different tiles. GroundTexturesBase contains 7x1 tiles. Next, select the texture you want to use. I'll select GroundTexturesBase.
Press Add Layer again. Name this new layer "Overlay" or "Overlay Layer". Set its type to Overlay and its width and height to however many tiles you texture contains. GroundTexturesOverlay contains 6x12 tiles. Select the texture you want to use and press Apply.

The inspector window will now display the textures you choose, sliced according to their width and height.When starting off, you'll see that the base layer tiles are all covered with a black X above them, signaling that they're not walkable. Clicking on it will change it to an O, changing it to a walkable tile. In the example below all tiles are walkable and should thereby be set to Os. The overlay will all have hyphens (-) over them. A hyphen means that it inherits the walkability of whatever tile lies underneath. An U means it overrides whatever lies underneath and makes it unwalkable and a W means it overrides whatever lies underneath and makes it walkable. When the walkability of a tile in the final map segment is calculated, each tile position checks through the layers to determine wether a position can be walked upon or not. Is the example below all tiles in the overlay layer inherits their value. Press Apply once more. The changes are now saved and the tile set is in the wanted state.

Create a map segment game object

Map segments are game objects in the world that uses tile sets to be drawn. The easiest way to create one is by clicking on Game Object in the top menu and then BonaTileEditor->MapSegment. A new Mapsegment should now be visible in the scene view (but not display anything) and in the Scene hierarchy. Select the map segment in the hierarchy view and give the game object a proper name.

In the inspector you will find the MapSegment component. Select it and pick a size for you map segment. I suggest something like 32x32. The max size of a map segment is 100x100. Next select a tile set on the line beneath. Select the tile set you created above. Once all is set, press Apply. The map segment should now exists in your scene view. The default tile for each layer is the bottom left one. This might result in the map segment looking a bit weird for now but that's easily fixed. There is not way to not paint a specific position. In case you want to leave something in overlays wholly transparent, a transparent tile must exists in the tile set texture. My suggestion is to put it in the bottom left corner as this is the default.

Paint your map segment

You are now ready to start having fun with your map segment. In the layer list you can select which layer you want to paint to. The entries in this list matches the one you created earlier in the tile set. Beneath that you can see the different paint tools available.
  • Mouse tool
    The default tool. It does nothing and is useful when you don't want to paint some tiles by mistake.
  • Pencil tool
    Freehand paint tools. Can paint however you like.
  • Box tool
    Allows you to paint solid boxes.
  • Fill tool
    Use this tool to paint the selected tile and all adjacent tiles of the same type.

Tile set changes

In case you make any changes to a tileset the changes are NOT automatically carried over to any map segment using that tileset. By pressing apply once on the mapsegment in the inspector, the changes should be copied again and be up to date.

Björn Fyrvall