Sean Barton - Game Developer

Better Control of Tiled2Unity Files in Your Unity Project

07 June 2015

Hi there! Tiled2Unity is no longer in development nor supported. Use SuperTiled2Unity to import Tiled Map Editor maps into your Unity projects instead.

Version 0.9.11.0 of Tiled2Unity has just been added to the Tiled2Unity Download Page. This build contains a couple of new features for power-users.

You Can Now Put Tiled2Unity Anywhere In Your Unity Project

I had originally hardcoded all the scripts that build a prefab from Tiled2Unity to exist at the Assets/Tiled2Unity directory. However, many developers prefer to gather all third-party libraries in a common location and I totally can’t blame them for wanting to put Tiled2Unity in a location like Assets/Scripts/ThirdParty/Tiled2Unity along with everything else. That is now supported with the latest build of Tiled2Unity.

One caveat: I had to change the way the Tiled2Unity exporter is made aware of your Unity project in order to export the right files to the right location. You will now have to explicitly select your Tiled2Unity scripts location in your Unity project instead of just selecting the project root folder. This is done by finding the Assets/Your/Path/To/Tiled2Unity/Tiled2Unity.export.txt file in your Unity project.

Tiled2Unity Exporting

The “Export To ...” button allows you to choose where to export Tiled maps within your Unity project.

Each install of Tiled2Unity in Unity contains an export marker file that must be selected as the export destination.

Tiled2Unity Export Open File Dialog

You will need to traverse into your Unity project to find the Tiled2Unity/Tiled2Unity.export.txt file. This will instruct the Tiled2Unity exporter where all the textures, materials, meshes, and prefabs will be created for use in your Unity project.

This is just a tiny bit more complicated than earlier builds of Tiled2Unity but I think the trade-off is worth it. Tiled2Unity will remember your last export destination so you won’t have to select this every time you export a Tiled map into your project.

Mark Tiled Maps as Resources For Object Instantiation

Most Tiled2Unity users will simply drop a Tiled2Unity generated prefab into their scene but some developers may want to instantiate a map prefab through script. However, Unity forces developers to place such assets in a Resources folder. This meant users would need to export a Tiled map into Unity then move the generated prefab into another folder by hand — which breaks automation.

With the latest version of Tiled2Unity you can mark a Tiled map with the unity:resource property like so …

Map Property unity:resource

Add a custom property with the name unity:resource (set value of True) to mark the map as a Unity resource. This will allow you to instantiate the map prefab via script.

Normally, Tiled map prefabs are constructed in the .../Tiled2Unity/Prefabs folder but with the unity:resource property they will reside in .../Tiled2Unity/Prefabs/Resources instead. With this you can easily instantiate the prefab in realtime via a Unity script, for example …

using System.Collections;

public class MapCreator : MonoBehaviour
{
    void Start()
    {
        UnityEngine.Object prefab = Resources.Load("MyTiledMapPrefab");
        GameObject.Instantiate(prefab);
    }
}

Developers employing some kind of procedural generated content scheme should find that useful.

Added Potential Bonus: Win32 Specific Code Removed

With this latest build I have gone through and removed all dependencies on unmanaged Win32 code (the old export dialog was a big offender). The Tiled2Unity exporter still doesn’t officially support any non-Windows platform but people wanting to make Mac or Linux versions run via Mono should have an easier time at it now.

Reminder: Tiled Map Editor has been totally free for years now. Please consider contributing to Thorbjorn Lindeijer’s Patreon for continued Tiled Map Editor support.

Seanba

Hi! My name is Sean Barton (aka Seanba).

I’m an American-Canadian software developer working in Austin, Texas where I never have to shovel snow. :fire:

My career focuses exclusively on video game software and tools. You can read more about me here.


Aseprite2Unity

Aseprite2Unity imports sprites and animations for use with your Unity projects. Like all my tools it is available for free or name your price.

Get Aseprite2Unity.


SuperTiled2Unity

SuperTiled2Unity is a collection of Unity scripts that import Tiled Map Editor files to your Unity projects. You can download for free or name your price.

Get SuperTiled2Unity.

(Note that regular Tiled2Unity is now deprecated.) :zzz:


Seanba

Like my tools? Consider making a donation as a way of thanks!