Better Control of Tiled2Unity Files in Your Unity Project

by Seanba on June 7, 2015

Version 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 UnityEngine;
using System.Collections;

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

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.

{ 9 comments… read them below or add one }

Benjamin P June 15, 2015 at 10:23 pm

unity:resource <—- Awesome! 🙂

James July 11, 2015 at 1:37 pm

With the new export option, I can’t seem to get the command line to work. For simplicity, say my unity project is in C:\Game and my Tiled2Unity.export.txt is in C:\Game\Assets\ThirdParty\Tiles2Unity

Well when I export manually I put the path to the export txt and it processes just fine.

When I run the command “c:\Program Files (x86)\Tiled2Unity\Tiled2Unity.exe” %mapfile C:\Game\Assets\ThirdParty\Tiled2Unity the tiled2unity window pops up with buttons enabled, but when pressing the big ass export button, I get the error:

UNITYDIR ‘C:\Game\Assets\ThirdParty\Tiled2Unity’ is not a Unity Project folder

This a bug or am I just doing things incorrectly?

Seanba sez: Hi James, that does appear to be a bug. I will get a fix up sometime this weekend. Thanks for the report and stay tuned.

Seanba sez (part deux): James, try the latest version from the download page ( That should put the command line features of Tiled2Unity back in working order. Apologies of the mess.

James July 11, 2015 at 9:47 pm

That seems to have fixed it. Thanks Sean for all your hard work and for providing this to the unity community.

Rafael August 11, 2015 at 5:32 pm

Great tool man… we appreciate this.

Hakan June 26, 2016 at 10:34 am

My unity gets stuck at importing the xml file and says “Error importing texture ‘Assets/Tiled2Unity/Textures/8x8_preset4.png’. Could not find material. Try re-importing Tiled2Unity/Imported/[MapName].tiled2unity.xml file”

Seanba sez: Hi Hakan, I recently fixed some problems with texture importing. Can you update to the latest version of Tiled2Unity and try again? (Don’t forget to update your Unity-side scripts too)

Chris July 3, 2016 at 7:29 pm

I still have the same problem / error message as Hakan. I am using the Mac Version.

Seanba sez: Hi Chris, the bug Hakan reported was fixed in a recent version of Tiled2Unity. Can you try updating and see if that works for you? Thanks.

Pedro Camacho D`Andrea November 7, 2016 at 6:09 pm

Hello, my name is Pedro, and I am currently on a Game Development Marathon, with final due date to 25/11/2016.

I have used TILED and TILED2UNITY to create the level for a 2D Platformer.

All the resources are working fine inside unity, but when we EXPORT TO WEBGL, the assets get bugged, stop showing entirely or some parts of them vanish/breaks.

Any advices on a fix, PLEASE?

Seanba sez: It appears that this is a problem with some WebGL implementations when using NPOT textures. As a rule, try to always use textures that are powers-of-two (64×64, 128×256, 512×512, etc..) for your tilesets. Most platforms don’t have this limitation but it’s a real pain when it shows up.

Benchmark04 January 27, 2017 at 2:02 pm

i have a question,
when i use a prefab-map in my scene und add some childs to some of the tiles adding things like scripts and colliders and stuff,
how can i prevent the overwriting everytime when i want to change the map with tiled and export it again?

Seanba sez: For that sort of thing you want a Custom Importer to edit the prefab for you. Such importers are invoked when the prefab is reconstructed and their job will be to add the child gameobjects, scripts. colliders, etc.. that you would otherwise do by hand. I talk about custom importers here:

Nicholas August 22, 2017 at 8:38 pm

Hey there!
Not sure if I’m missing something. But I’ve installed Tiled2Unity to my project (lets say it’s at C:/Project/Assets/Tiled2Unity) and I can export to the folder targeting the installed Tiled2Unity.export.txt file.

I want to export to a different folder (ex: C:/Project/Assets/Levels), but I can only get it to work if I copy over all of the contents inside the Tiled2Unity folder (i.e. the prefabs/materials etc).

I would like to be able to select the corresponding folder (Levels/Level01) and export the map to there. Then the next map, target Levels/Level02 if I wanted to. But if the above is the only way, then I would have to move the entire folder heirarchy every time, or have copies in every level folder.

Am I missing something, or is that the only way to change where it exports to? Otherwise, I have move and overwrite the prefab that I’m using in the game, and of course that has the possibility to losing the reference link and other obvious annoyances.

Thanks for the help!

Leave a Comment

Previous post:

Next post: