Pixel Art Sprite Generator and C# Importer for Unity 2D
Zero post-processing cleanup between generation and engine playback
One-click C# Editor automation (no manual Sprite Editor slicing)
UnitySpriteForgeImporter.cs reads Celgrid's sprite.json manifest, configures every individual frame PNG in frames/, writes normalized bottom-center pivots (x/w, 1 - y/h), and creates a ready-to-play .anim AnimationClip.
Automatic Point filtering and zero compression artifacts
Unity defaults to Bilinear filtering and DXT/BC7 compression, which turns crisp 16x16 pixel art into green/magenta blocks. Celgrid's importer enforces FilterMode.Point, TextureImporterCompression.Uncompressed, and mipmapEnabled = false on every frame.
Consistent Pixels Per Unit (PPU) across entire rosters
Because Celgrid locks exact canvas dimensions per project (16x16, 24x24, or 32x32), your Unity tilemap grid and Pixel Perfect Camera PPU stay aligned without uneven sub-pixel scaling.
Exact frame timing preserved in AnimationClip
Celgrid's importer reads duration_ms directly from sprite.json and sets AnimationClip frameRate, ObjectReferenceKeyframe timings, and loopTime automatically.
Exact Unity 2D files generated from Frontline Soldier Walk (16x16, 6 frames)
These snippets are produced directly by Celgrid's live exporter (sheet_export.py) — never hand-faked placeholder code.
// Install once as Assets/Editor/SpriteForgeImporter.cs; select sprite.json from an extracted pack.
using System;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
public static class SpriteForgeImporter
{
[Serializable] class Manifest { public Sheet spritesheet; }
[Serializable] class Sheet { public Frame[] frames; public string tag; public bool loop; }
[Serializable] class Frame { public string name; public int source_width, source_height; public float duration_ms; public int[] pivot; }
[MenuItem("Assets/SpriteForge/Import animation", true)]
static bool CanImport() => Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)) == "sprite.json";
[MenuItem("Assets/SpriteForge/Import animation")]
static void Import()
{
string path = AssetDatabase.GetAssetPath(Selection.activeObject);
string folder = Path.GetDirectoryName(path).Replace('\\','/');
var sheet = JsonUtility.FromJson<Manifest>(File.ReadAllText(path)).spritesheet;
var keys = new ObjectReferenceKeyframe[sheet.frames.Length + 1];
float time = 0;
for (int i = 0; i < sheet.frames.Length; i++)
{
var frame = sheet.frames[i];
string png = folder + "/frames/" + frame.name + ".png";
var importer = AssetImporter.GetAtPath(png) as TextureImporter;
if (importer == null) throw new IOException("Missing frame " + png);
importer.textureType = TextureImporterType.Sprite;
importer.spriteImportMode = SpriteImportMode.Single;
importer.mipmapEnabled = false;
importer.filterMode = FilterMode.Point;
importer.textureCompression = TextureImporterCompression.Uncompressed;
var settings = new TextureImporterSettings();
importer.ReadTextureSettings(settings);
settings.spriteAlignment = (int)SpriteAlignment.Custom;
settings.spritePivot = new Vector2((float)frame.pivot[0]/frame.source_width, 1f-(float)frame.pivot[1]/frame.source_height);
importer.SetTextureSettings(settings);
importer.SaveAndReimport();
var sprite = AssetDatabase.LoadAllAssetsAtPath(png).OfType<Sprite>().Single();
keys[i] = new ObjectReferenceKeyframe { time = time, value = sprite };
time += frame.duration_ms / 1000f;
}
keys[keys.Length-1] = new ObjectReferenceKeyframe { time = time, value = keys[keys.Length-2].value };
var clip = new AnimationClip { frameRate = 1000f/sheet.frames[0].duration_ms };
var binding = EditorCurveBinding.PPtrCurve("", typeof(SpriteRenderer), "m_Sprite");
AnimationUtility.SetObjectReferenceCurve(clip, binding, keys);
var timing = AnimationUtility.GetAnimationClipSettings(clip);
timing.loopTime = sheet.loop;
AnimationUtility.SetAnimationClipSettings(clip, timing);
AssetDatabase.CreateAsset(clip, AssetDatabase.GenerateUniqueAssetPath(folder+"/"+sheet.tag+".anim"));
AssetDatabase.SaveAssets();
Selection.activeObject=clip;
}
}
{
"id": "01b956ac6b13",
"title": "Frontline Soldier Walk",
"width": 16,
"height": 16,
"spritesheet": {
"tag": "walk",
"fps": 9.0,
"loop": true,
"frames": [
{
"index": 0,
"x": 0,
"y": 0,
"width": 16,
"height": 16,
"trim": [
0,
0,
16,
16
],
"source_width": 16,
"source_height": 16,
"name": "walk_000",
"duration_ms": 111.11111111111111,
"pivot": [
8,
15
]
},
{
"index": 1,
"x": 16,
"y": 0,
"width": 16,
"height": 16,
"trim": [
0,
0,
16,
16
],
"source_width": 16,
"source_height": 16,
"name": "walk_001",
"duration_ms": 111.11111111111111,
"pivot": [
8,
15
]
}
]
}
}How to import Celgrid pixel art into Unity 2D in four steps
Install UnitySpriteForgeImporter.cs once in your Unity project
Copy UnitySpriteForgeImporter.cs.txt from any downloaded Celgrid pack.zip into Assets/Editor/SpriteForgeImporter.cs. Unity compiles the menu item Assets > SpriteForge > Import animation automatically.
Extract your Celgrid sprite pack into Assets/Sprites/
Keep sprite.json alongside the frames/ folder inside a dedicated subfolder such as Assets/Sprites/FrontlineSoldier/.
Select sprite.json and run the importer
Click sprite.json in the Unity Project window, open Assets > SpriteForge > Import animation, and Unity generates the configured Sprite assets plus the .anim clip with custom pivots and loop settings.
Match Pixels Per Unit (PPU) to your tile grid
Use 16 PPU for 16x16 starter packs (Meadowkeep, Frontline 1944), 24 PPU for 24x24 packs (Cryptbound, Sunspire Tactics), or 32 PPU for Arcade Platformer 32x32 sprites with Unity's 2D Pixel Perfect Camera.
Recommended Pixels Per Unit (PPU) for Celgrid sprite grids
| Celgrid Native Grid | Unity PPU | Tile Scale | Pixel Perfect Camera Reference |
|---|---|---|---|
| 16x16 (Meadowkeep, Frontline 1944) | 16 PPU | 1 world unit = 1 tile | 320x180 or 480x270 ref resolution |
| 24x24 (Cryptbound, Sunspire Tactics) | 24 PPU | 1 world unit = 1 hero cell | 480x270 or 640x360 ref resolution |
| 32x32 (Arcade Platformer preset) | 32 PPU | 1 world unit = 1 large tile | 640x360 ref resolution |
Unity 2D Pixel Art FAQ
How does Celgrid convert pixel pivots from top-left to Unity bottom-left coordinates?
Celgrid stores pixel anchors from top-left origin [px, py] in sprite.json. The bundled UnitySpriteForgeImporter.cs converts them automatically to Unity normalized coordinates via new Vector2((float)px / width, 1f - (float)py / height).
Why do AI sprites usually look blurry or discolored in Unity?
Two reasons: diffusion generators output anti-aliased sub-pixels, and Unity defaults to Bilinear filtering with lossy texture compression. Celgrid fixes both by generating exact indexed RGBA grids and applying FilterMode.Point with Uncompressed textures during import.
Does the Unity importer work with URP 2D and Pixel Perfect Camera?
Yes. The importer creates standard Unity Sprite assets and SpriteRenderer m_Sprite AnimationClips compatible with Built-in 2D, URP 2D Renderer, 2D Lights (using optional diffuse/light maps), and the 2D Pixel Perfect package.
Can I adjust animation FPS after importing without regenerating pixels?
Yes. Change FPS (0.5 to 60) directly in Celgrid Studio or via POST /v1/pixel-assets/{id}/timing at 0 credits, or adjust the sample rate on the generated Unity .anim clip.
Compare all lossless engine export pipelines
Ship crisp Unity 2D pixel art today
Start with 25 free starter credits (verified signup) plus 4 complete starter packs and zero-credit manual editing and exports.