Importing tilesets into Unity with Tiled2Unity

Now, this is where Tiled2Unity comes in handy. Once you have created your Tilemap in Tiled, we need to bring it into Unity so that the player will be able to interact with it.

Generally, most of the things that we have completed using third-party software can be done manually within Unity itself; however, third-party tools offer a way to increase efficiency, and in some cases, the output. In saying that, I do encourage you to explore the ways that you could complete these tasks within Unity, even if they are time-consuming. In the event that such programs are no longer available, it is useful to know the "manual" way to achieve the same results.

When you open Tiled2Unity, you will see a window like the following screenshot:

While initially this may be quite daunting, the whole process is very simple. To import our Tilemap from Tiled, simply:

  1. Open/create your project Unity (if you haven't already).
  2. In Tiled2Unity, navigate to Help | Import Unity Package To Project.

  1. In Unity, a dialogue box will open. Now, click on Import. An example of this can be seen in the following screenshot. At this stage, all that is happening is Tiled2Unity is setting up the plugin within Unity. As a result, we can then use the Tilemap files (from Tiled) that we are about to import next:
  2. In Tiled2Unity, navigate to File | Open Tiled File….
  3. Select your Tiled (.tmx) file and click Open.
  4. Set your Pixels per Unit value in such a way that you are happy with your scale. Keep in mind that this value tells us how long a pixel is in the World Units of Unity. This might take some trial and error, especially when you are working on larger projects. However, once you have found an appropriate value to use, you should keep it consistent throughout your project, unless you have specific needs. In this book, we will go for a value equal to 0.02.
  5. Next, click Export To… and specify the location within your Unity project. This file should be inside the folder Assets/Tiled2Unity and called Tiled2Unity.export.
  1. If necessary, click the Preview Map to make sure that you have the right Tilemap. You can see an example of this in the following screenshot:
  2. Lastly, click the Export button to export the Tilemap to Unity.

And voila. We are now finished with Tiled2Unity, so it's time to head back into Unity to continue making our game, which we will begin in Chapter 9, Look, It Moves.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset