Home Guides

How to get a TileMap Studio map into Unity

Export your map as a Tiled .tmx and import it with the free SuperTiled2Unity package, which builds Unity Tilemaps for you. If you would rather not add a package, export the CSV grid and place the tiles with the short C# loader below.

Updated

  1. In TileMap Studio, choose File → Export → Tiled map (.tmx).
  2. Put your tileset PNG next to the .tmx, named exactly as the tileset is named in the editor (the file refers to <tileset name>.png).
  3. Install SuperTiled2Unity (free, by Seanba) into your project.
  4. Drag both files into Assets. Unity imports the .tmx as a prefab: a Grid with one Tilemap per layer. Drag it into your scene.

Autotiled terrain comes through correctly: the .tmx carries a half-tile <tileoffset> for the terrain atlas, so the dual-grid terrain lines up with your other layers.

Option 2: load the CSV with C#

The CSV export holds every layer as a grid of GIDs (0 = empty), each layer under a # layer: Name line. This script places one layer onto a Unity Tilemap.

  1. Export File → Export → CSV grid and add the .csv to Assets (Unity reads it as a TextAsset).
  2. Slice your tileset sprite (Sprite Mode: Multiple, Grid By Cell Size) and create a Tile Palette from it, which gives you one Tile asset per tile.
  3. Add the script to a GameObject, assign the CSV, the target Tilemap and the tiles array in tileset order (left to right, top to bottom).
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;

// Places one layer of a TileMap Studio CSV export onto a Tilemap.
public class TileMapStudioLoader : MonoBehaviour
{
    public TextAsset csv;
    public string layerName = "Ground";
    public Tilemap tilemap;
    public TileBase[] tiles;   // in tileset order: index = GID - firstGid
    public int firstGid = 1;   // 1 for the first tileset in the map

    void Start()
    {
        var rows = new List<string>();
        bool inLayer = false;
        foreach (var raw in csv.text.Split('\n'))
        {
            var line = raw.Trim();
            if (line.StartsWith("# layer:")) { inLayer = line.Substring(8).Trim() == layerName; continue; }
            if (inLayer && line.Length > 0) rows.Add(line);
        }
        for (int y = 0; y < rows.Count; y++)
        {
            var cells = rows[y].Split(',');
            for (int x = 0; x < cells.Length; x++)
            {
                int i = int.Parse(cells[x]) - firstGid;
                if (i >= 0 && i < tiles.Length)
                    tilemap.SetTile(new Vector3Int(x, rows.Count - 1 - y, 0), tiles[i]);
            }
        }
    }
}

Rows are flipped (rows.Count - 1 - y) because Unity's y axis points up. For an autotiled terrain layer, move its Tilemap by half a cell (−0.5, +0.5 in grid units) so it lines up.

Import settings for crisp pixels

  • Filter Mode: Point (no filter).
  • Compression: None.
  • Pixels Per Unit: your tile size (16 or 32), so one tile is one Unity unit.
  • Add a Pixel Perfect Camera to stop tiles shimmering when the camera moves.

Questions

Can Unity import Tiled .tmx maps?

Not natively, but the free SuperTiled2Unity package imports .tmx files as prefabs with a Grid and one Tilemap per layer.

Which TileMap Studio export is best for Unity?

The .tmx with SuperTiled2Unity is the least work. The CSV grid is best if you want a tiny loader with no dependencies.

Why is my map upside down in Unity?

Unity's tilemap y axis points up, while map files list rows from the top. Flip the row index when placing tiles, as the script on this page does with rows.Count - 1 - y.

How do I stop pixel art tiles blurring in Unity?

Select the tileset texture, set Filter Mode to Point (no filter) and Compression to None, and set Pixels Per Unit to your tile size.

Paint your Unity level

Open the free editor