Manual Ship

On this page
  1. Export
  2. Import it
  3. Options
  4. Pitfalls
  5. Next

Unity

Export a sprite as a pre-sliced, point-filtered Unity sprite atlas with a pivot at the feet (experimental).

The unity format writes the atlas PNG with a ready Unity .meta file. Drop both into a Unity project and the atlas imports as a pixel-art sprite sheet: point filtering, no compression, no mipmaps, and one named sprite per frame, each with its pivot at the feet.

Warning

The unity format is experimental: its file layout may change in a minor release, because Unity's importer format differs slightly between versions. It targets Unity 2021 LTS, 2022 LTS and Unity 6. mode8 schema --section formats shows the stability of every format.

The hero atlas as the .meta file slices it: a named rectangle around each of the nine frames and a pivot mark at the feet
hero_atlas.png with the sprite rects and pivots from hero_atlas.png.meta

Export#

Make a starter project to follow along, then export its hero:

bash
mode8 init my-game --template platformer
cd my-game
terminal
$ mode8 export assets/hero/frames --out-dir exports/unity --name hero --formats unity --animations assets/hero/master.m8.json
✓ Exported hero (15 frames) → exports/unity/
  unity · 15 files
  animations attack, hurt, idle, jump, walk
  palette nes_master_gothic from mode8.toml

Next:
  mode8 verify --assets-dir exports/unity

You get two files that belong together:

  • hero_atlas.png, the packed frames (plus hero_atlas.json, the same atlas JSON every engine format writes);
  • hero_atlas.png.meta, the import settings Unity reads for that PNG.

The .meta sets what pixel art needs, and slices the frames by name:

terminal
$ grep -E 'filterMode|spriteMode|spritePixelsToUnits|alphaIsTransparency|textureCompression' exports/unity/hero_atlas.png.meta
    filterMode: 0
  spriteMode: 2
  spritePixelsToUnits: 16
  alphaIsTransparency: 1
    textureCompression: 0
$ grep -A8 'name: idle' exports/unity/hero_atlas.png.meta
      name: idle
      rect:
        serializedVersion: 2
        x: 1
        y: 147
        width: 64
        height: 72
      alignment: 9
      pivot: {x: 0.5625, y: 0}
--
      name: idle_1
      rect:
Show 27 more lines
        serializedVersion: 2
        x: 66
        y: 147
        width: 64
        height: 72
      alignment: 9
      pivot: {x: 0.5625, y: 0}
--
      name: idle_2
      rect:
        serializedVersion: 2
        x: 131
        y: 147
        width: 64
        height: 72
      alignment: 9
      pivot: {x: 0.5625, y: 0}
--
      name: idle_3
      rect:
        serializedVersion: 2
        x: 196
        y: 147
        width: 64
        height: 72
      alignment: 9
      pivot: {x: 0.5625, y: 0}

filterMode: 0 is Point (no filter), spriteMode: 2 is Multiple (one sprite per frame) and textureCompression: 0 keeps every color exact. Each sprite's alignment: 9 is a custom pivot, at the feet, in Unity's bottom-left texture space.

Import it#

  1. Copy hero_atlas.png and hero_atlas.png.meta into your project's Assets/ folder, together, while the Unity editor is open or closed.
  2. Select the atlas in the Project window: Texture Type is Sprite (2D and UI), Sprite Mode is Multiple, and its arrow unfolds the frames idle, walk_0 and so on.
  3. Drag a frame into the scene. It stands on its feet at the GameObject's position.

To animate, select an animation's frames (for example walk_0 to walk_3) and drag them into the Scene view together; Unity makes an Animation Clip and an Animator for them. Set the clip's sample rate (Show Sample Rate in the Animation window's menu) to the animation's fps from hero_atlas.json:

terminal
$ sed -n '/"animations"/,/"hurt"/p' exports/unity/hero_atlas.json
  "animations": {
    "attack": {
      "frames": [
        "windup",
        "attack",
        "recover"
      ],
      "fps": 8,
      "loop": false,
      "durations": [
        2,
        1,
Show 4 more lines
        2
      ]
    },
    "hurt": {

Mode 8 does not write Animation Clips yet.

Options#

  • --pixels-per-unit N (1 to 4096, default 16) sets how many pixels make one Unity unit. Use the same value for every sprite and tile in a game, and match your camera to it (the 2D Pixel Perfect Camera's Assets Pixels Per Unit).
  • --guid-namespace NAME mixes a name into the file's GUID and sprite IDs. They are derived from the export name and the frame names, so exporting again keeps every reference (prefabs, clips, scenes) intact. Two different projects that both export a hero into one Unity project would collide; give each its own namespace:
terminal
$ mode8 export assets/hero/frames --out-dir exports/unity --name hero --formats unity --pixels-per-unit 32 --guid-namespace my-game
✓ Exported hero (15 frames) → exports/unity/
  unity · 15 files
  animations attack, hurt, idle, jump, walk
  palette nes_master_gothic from mode8.toml

Next:
  mode8 verify --assets-dir exports/unity

Pitfalls#

  • The frames are not sliced. The .meta did not travel with the PNG, so Unity made its own. Delete the atlas from Assets/, then copy both files again.
  • Blurry or banded sprites. Something changed the import settings after the import: set Filter Mode back to Point (no filter) and Compression to None, or copy the .meta again.
  • The sprite floats or sinks. Every frame shares the pivot of the idle frame. A hand-made sprite with feet at another height needs its own pivot in the Sprite Editor.

Next#