# Spine animation for Unity

> Load an Animate4Me Spine 4.2 export in Unity with the official spine-unity runtime: file names, straight alpha settings and C# code to play idle and win.

Page: https://animate4me.com/spine-animation-for-unity.html

This guide shows how to bring a Spine 4.2 animation made with Animate4Me into a Unity project and play it from C#. It uses the official **spine-unity** runtime from Esoteric Software, so the animation plays exactly as in the browser preview.

You need a Unity project, the spine-unity runtime for Spine 4.2 and a Spine 4.2 export: either your own from the app or our [example export](https://animate4me.com/download/animate4me_ring_v2_spine42.zip) (0.5 MB, a ring with symbol and object animations).

[Try it](https://animate4me.com/app.html) [See pricing](https://animate4me.com/pricing.html)

## How do I use an Animate4Me animation in Unity?

Animate4Me gives you a Spine 4.2 export that the official spine-unity runtime loads like any export from the Spine editor.

**Best for:** Unity developers who need animated icons, items, props or characters without rigging them by hand.

**Key advantages:**

- Standard Spine 4.2 JSON, atlas and PNG: no custom importer.
- Named animations such as `idle` and `win`, played with `SetAnimation`.
- Loop-perfect idles; `win` returns to the first frame of `idle`.
- Straight-alpha pages that work in Linear and Gamma color space.

**What you get:** one ZIP with skeleton.json, skeleton.atlas, a PNG page and a README; 20 tokens per symbol or object from your image.

## Before you start

- **Match the version.** The export is Spine 4.2 data. Use a spine-unity runtime of the 4.2 line; Esoteric Software asks that the runtime major.minor version matches the export version.
- **Install spine-unity.** Get the 4.2 unitypackage from the Spine website, or add the spine-unity UPM packages, as described in the official spine-unity installation docs.
- **Spine licence.** Using a Spine Runtime in your product needs your own Spine licence from Esoteric Software.

## Step 1: get the export

Make the animation in the [app](https://animate4me.com/app.html) from an image or a prompt, pick the templates (for a game symbol, for example `idle`, `land` and `win`), check it in the preview and download the ZIP. What is inside:

- `skeleton.json`: Spine 4.2 skeleton data with bones, weighted meshes and one named animation per template you chose (for example `idle` and `win`).
- `skeleton.atlas`: the texture atlas description. Its header says `pma: false`: the pages are straight alpha, not premultiplied.
- `skeleton.png`: the atlas page. A symbol or object export is one page, usually about 450 to 1,500 px on each side, in a ZIP of about 0.1 to 1.8 MB.
- `README.txt`: the animation list and loading notes.

## Step 2: rename the atlas for Unity

spine-unity reads the atlas as a text asset, so the atlas file must end in `.atlas.txt`. Rename `skeleton.atlas` to `skeleton.atlas.txt`. Do not rename the PNG: the atlas file refers to it by name.

Every export uses the names `skeleton.*`, so give each animation its own folder, for example `Assets/Spine/ring/`.

## Step 3: set straight alpha

Our atlas pages are **straight alpha** (the atlas header says `pma: false`). spine-unity 4.2 expects premultiplied alpha by default, and a mismatch shows as dark or light borders around the art. Before you import, open **Edit > Preferences > Spine** (on macOS under the Unity menu) and set **Atlas Texture Settings** to `StraightAlphaTexturePreset` and the blend mode materials to `SkeletonStraightAdditive`, `SkeletonStraightMultiply` and `SkeletonStraightScreen`.

If the files are already imported, enable **Straight Alpha Texture** on the generated material and keep **sRGB** and **Alpha Is Transparency** on for the texture, as the spine-unity docs describe for the straight alpha workflow.

## Step 4: import and place it

1. Drag the folder with `skeleton.json`, `skeleton.atlas.txt` and `skeleton.png` into your Project window.
2. spine-unity creates `skeleton_Atlas`, `skeleton_Material` and `skeleton_SkeletonData` next to them.
3. Drag `skeleton_SkeletonData` into the Scene and choose **SkeletonAnimation**. For a UI Canvas use **SkeletonGraphic** instead, and check that its material is set up for straight alpha too.
4. In the Inspector pick the animation name, tick **Loop** for `idle`, and press Play.

The export is sized in pixels. spine-unity applies the **Scale** of the Skeleton Data Asset (0.01 by default, so 100 px is one Unity unit); change it there if the animation is too big or too small.

## Step 5: play idle and win from C#

Attach this script to the same GameObject as the `SkeletonAnimation`. It loops `idle`, and `PlayWin()` plays `win` once, then goes back to `idle`. Because `win` ends on the first frame of `idle`, the change back is seamless.

```
using Spine.Unity;
using UnityEngine;

public class SymbolAnimation : MonoBehaviour
{
    SkeletonAnimation skeletonAnimation;

    void Awake()
    {
        skeletonAnimation = GetComponent<SkeletonAnimation>();
    }

    void Start()
    {
        // track 0, animation name, loop
        skeletonAnimation.AnimationState.SetAnimation(0, "idle", true);
    }

    public void PlayWin()
    {
        skeletonAnimation.AnimationState.SetAnimation(0, "win", false);
        // queue idle after win ends (delay 0 = when win finishes)
        skeletonAnimation.AnimationState.AddAnimation(0, "idle", true, 0f);
    }
}
```

The animation names in your file are the templates you chose in the app, for example `land`, `dissolve` or, for objects, `appear`, `open` and `collect`. The README in the ZIP lists them.

## Troubleshooting

- **Dark or bright fringes around the art:** the alpha setting does not match. Use the straight alpha settings from step 3.
- **The atlas is not picked up:** check that the file ends in `.atlas.txt` and sits in the same folder as the PNG.
- **"Skeleton version" or parse errors:** the runtime is not 4.2. Install spine-unity 4.2.
- **Two exports overwrite each other:** keep each export in its own folder.

## How much does it cost?

A symbol or object animation from your image costs **20 tokens**, from a text prompt **30 tokens**; a character costs **60 tokens** from an image. Tokens come with a monthly plan: **Indie** $19 a month for 300 tokens, **Studio** $59 a month for 1200 tokens, **Pro** $199 a month for 5000 tokens. There is no free trial and there are no free tokens. Your first plan payment comes with a 7-day money-back, see the [Refund Policy](https://animate4me.com/refund.html); if an animation fails on our side, its tokens are returned automatically.

## Questions and answers

### Which spine-unity version do I need?

A spine-unity runtime of the 4.2 line. The export is Spine 4.2 data, and the runtime major.minor version must match the export version.

### Why are there dark edges around my animation in Unity?

The atlas pages are straight alpha, while spine-unity 4.2 expects premultiplied alpha by default. Set the straight alpha texture preset and materials in the Spine preferences, or enable Straight Alpha Texture on the material.

### Can I use it in a Unity UI Canvas?

Yes. Drag the SkeletonData asset into a Canvas to get a SkeletonGraphic component, and make sure its material is set up for straight alpha too.

### Can I get a binary.skel file instead of JSON?

The export is Spine 4.2 JSON. If you own the Spine editor you can import the JSON there and export it again as binary (.skel.bytes for Unity).

### Do I need a Spine licence?

The exported files are yours. To play them in your own product with an official Spine Runtime you need your own Spine licence from Esoteric Software, the same as for any Spine export.

## Related

- [Spine animation for Godot](https://animate4me.com/spine-animation-for-godot.html)
- [Spine export for game engines](https://animate4me.com/spine-export-for-game-engines.html)
- [Image to Spine animation](https://animate4me.com/image-to-spine.html)
- [Batch-animate game assets with the API](https://animate4me.com/batch-animate-game-assets-api.html)
- [Animate4Me home](https://animate4me.com/)

## Make a Spine animation for your Unity game.

[Try it](https://animate4me.com/app.html)

[Plans and token prices](https://animate4me.com/pricing.html)

---

Animate4Me: https://animate4me.com/ · Contact: contact@animate4me.com · X: https://x.com/Animate4Me · All pages for AI assistants: https://animate4me.com/llms.txt

Spine is a trademark of Esoteric Software. Animate4Me is not affiliated.
