Sean Barton - Game Developer

Revisiting Tiled2Unity Scale with Scaled Vertices

01 March 2015

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

Scaled Vertices

A while back I offered a solution for Tiled2Unity users that wanted to partner scaled sprites (using a Pixels Per Unit value that was often the 100:1 default) with exported maps that used the (totally more sane) metric of one pixel per one unit in Unity.

Turns out that solution sucked. (more below)

Now, starting with Tiled2Unity, the desired scaling can be baked into the vertices that make up your meshes and collision geometry.

You can set the vertex scale in the Tiled2Unity UI:

Scaled Vertices in Tiled2Unity UI

Or you can use a command line argument (-s=VALUE or --scale=VALUE).

  • From Tiled: Tiled2Unity.exe %mapfile <span style="background-color: #ffff00">-s=0.01</span> c:\My\Unity\Project\Folder
  • From command line: Tiled2Unity.exe c:\My\Map\Folder\MyMap.tmx <span style="background-color: #ffff00">--scale=0.01</span>

Both examples scale your vertices down to 1/100th of a unit which will be the most common. You can use other values though.


Problem With the Original Solution

The old way of scaling your exported maps was to instruct Tiled2Unity to hardwire the Transform component of the created prefab so that its scale matched the unity:scale map property in your TMX files. This became be a problem should GameObjects transfer in and out of your object hierarchy which is a common enough thing someone may want to do.

Not to beat a dead horse (and I say this as someone with a ton of enthusiasm for Unity) but I view the Pixels Per Unit setting in Unity to be a huge hack just to get sprites working with Box2D Physics which is a bad idea anyway for retro 2D games. I just don’t use it. However, if that’s the way you roll I now encourage you to use vertex scaling to get the job done.

If you decide to go this route keep in mind that the unity:scale property is still honored so make sure to rip it out of your TMX files. Otherwise, you’ll end up with prefabs that are scaled twice over.

Happy developing.

Update: User Adam offers an alternative way to think of scale in relation to physics …

For games that do use the physics engine, it seems to me that setting the pixels per unit to the size of your tiles makes sense, in my case 16. That’s because as far as the physics engine is concerned, one unit is one meter. With a tile size of 16, 100 gives you colliders that are too small and 1 gets into some large values that make me worry about floating point errors.

I can’t argue that. For people relying on the built-in 2D physics provided by Unity this sounds like a reasonable approach.

By the way: If you enjoy using Tiled then please consider contributing to Thorbjorn Lindeijer’s Patreon so that he can work on Tiled fulltime. It’s a great deal for our development community. Even a buck or two per month helps.


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.


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:


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