Sean Barton - Game Developer

Object Type Support Added to Tiled2Unity

17 April 2016

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

This is an update I’ve been waiting awhile for. Recently, Tiled has been updated with better support for Object Types.

Tiled Object Types Editor

The new Object Types Editor in Tiled allows you create type templates with default properties. With Tiled2Unity 1.0.5.0 these types can automatically be broken up into distinct collision “layers”. Default properties can also be passed on to custom importers in Tiled2Unity.

Additionally, the Tile Collision Editor now allows you to set properties on an Object Group or Collision basis.

Improved Tile Collision Editor

With the new Tile Collision Editor you can assign types to each rectangle, polygon, or polyline collider you add to a tile. You can even have collisions of different types on any tile.

What doess this mean for Tiled2Unity? With earlier versions of the utility it could be cumbersome to manage the different collision types you have on your map. For example, say you had a map in Tiled that contained three different collision types …

Single Tiled Layer with 3 Different Collider Types

Even though all these tiles could be easily placed on the same Tiled layer you would be forced to put them into separate layers, each with a unity:layer custom property on them, in order for them to be exported to Unity as separate Default, Ladders, and Spikes collision objects.

Now, with the latest Tiled and Tiled2Unity, you can simply create new types in the Object Types Editor …

Adding Object Types in Tiled

Here I'm adding new object types for the kinds of colliders I'm interested in (Default, Ladders, and Spikes). The exported TMX map will result in a prefab that breaks out collider objects into these categories.

… and use those types in the Tile Collision Editor …

Setting Type in Collision Editor

Through the Collision Editor we can select the ladder tile and add a collider that uses the Ladders type. Now I can use that tile on any Tile Layer and let the export process do the rest.

… and the collision tiles will be combined into PolygonCollider2d objects of the same type for you automatically …

Preview Using Object Type Colors

Here you can see how the tiles are combined with other colliders of the same type. Note you will need to make Tiled2Unity aware of your Object Types XML file in order to use the same color scheme you set in Tiled.

This is done without the need for a custom unity:layer property. Note that the unity:layer property is still obeyed however if used. This is useful if you have a special Tile Layer that you want to force into a particular collision type.

Note that in order to see the collision type colors in the previewer that you will need to point Tiled2Unity to an Object Types XML file. I suggest you export that file (from the Object Types Editor in Tiled) to the same folder you keep your maps in and keep it updated.

Object Types XML in Tiled2Unity

You only need to set the Object Types XML file if you a) Want to see object type colors in the Previewer or b) You have default object property settings you want passed on to custom importers in your Unity project during export.

Default Object Type Properties Exported Too

Many users won’t need to worry about setting the Object Types XML when exporting their Tiled maps. However, if you want default properties to be exported with any Tile Objects to be consumed by a Custom Importer then you will need this setting.

Note: For Tiled2UnityLite users (Mac and Linux) you will want to pass the path to your Object Types XML as a command line option. For example:

Tiled2UnityLite.cs <span style="color: #333399;">-o=/Your/Path/To/objecttypes.xml</span> $TMXPATH $UNITYDIR

Tiled2UnityLite.cs <span style="color: #333399;">--object-type-xml=/Your/Path/To/objecttypes.xml</span> $TMXPATH $UNITYDIR

Bug Reports Always Welcome

I like to think I do a pretty good job of testing new features added to Tiled2Unity, but, because of reasons, the magnitude of this update is larger than normal. If you experience odd behavior or a fatal crash please send me an email so I can be aware of it.

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.


Seanba

SuperTiled2Unity is my new 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!