gif→sprite sheet

Unity

How to slice a sprite sheet in Unity (Unity 6)

Slice a sprite sheet in Unity 6 with Grid By Cell Size: import settings, working out cell size and padding, making the clip, and fixes for blur and bleeding.

Updated 9 min read

Select the sheet in the Project window, set Texture Type to Sprite (2D and UI) and Sprite Mode to Multiple, click Open Sprite Editor, then Slice → Grid By Cell Size, enter the width and height of one frame, click Slice and then Apply. That’s the whole job when the sheet is a clean grid. Most of this page is about the sheets that aren’t, because that’s where people lose an afternoon.

Everything below was checked against the Unity 6 manual (the 6000.0 pages).

Set up the import first

Do this before slicing. One of these settings can resize the texture, and a resized texture throws off every number you type into the grid afterwards.

  1. Drag the PNG into the Project window and select it.
  2. In the Inspector, set Texture Type to Sprite (2D and UI).
  3. Set Sprite Mode to Multiple. On Single, Unity treats the whole image as one sprite and the Slice button isn’t available.
  4. Set Pixels Per Unit. This is how many pixels of the image cover one world unit. For a 32×32 character that should stand one unit tall, use 32. Use the same value on every sheet in the game, or sprites will come out at different scales.
  5. For pixel art, set Filter Mode to Point (no filter) and, in the Default tab at the bottom, Compression to None.
  6. In the same tab, check Max Size. It has to be at least as large as the sheet’s longest side.
  7. Click Apply at the bottom of the Inspector.

Step 6 is the one tutorials skip. If the file is larger than Max Size, Unity scales it down on import, without an error. Third-party guides report the default as 2048 (the manual page doesn’t state it), so a 20-frame strip of 128 px frames, 2560 px wide, gets shrunk. Your 128×128 cell size is then wrong, and the art is soft even with Point filtering.

Slice the sheet in the Sprite Editor

  1. With the texture selected, click Open Sprite Editor in the Inspector.
  2. Click Slice in the Sprite Editor toolbar and set Type to Grid By Cell Size.
  3. Type one frame’s width and height into Pixel Size. Unity draws red outlines as a preview. Zoom in on the last column and the bottom row: if the outlines cut through the art there, the numbers are off.
  4. Leave Offset and Padding at 0 unless the sheet has a margin or gaps (more on those below).
  5. Pick a Pivot. Bottom suits anything that stands on the ground, Center suits projectiles and effects.
  6. Click Slice, then Apply in the Sprite Editor toolbar.

The second Apply is separate from the one in the Inspector, and the slices aren’t saved until you click it. Afterwards the texture in the Project window has an arrow next to it. Expand it and each frame is there as its own sprite, named after the texture with a number on the end: hero_0, hero_1 and so on.

Which slice type to use

TypeYou give itUse it when
Grid By Cell SizePixel Size (width and height of one frame)You know the frame size. The right choice for animation sheets.
Grid By Cell CountColumn & RowYou can count the frames but don’t know their size.
AutomaticNothing (it reads transparency)Icons or props of mixed sizes with transparent pixels between them.
Isometric GridPixel Size, plus Is Alternate for staggered rowsIsometric tiles that need diamond-shaped sprites.

I’d keep Automatic away from anything that animates. It fits a rectangle to each drawing, so a frame with an arm stretched out comes back wider than the frame next to it, and the pivot lands in a different spot on each. The character then shuffles sideways when the clip plays. A fixed grid gives every frame the same box. If the sheet is a pile of items or UI icons, ignore me and use Automatic, that’s what it’s for.

Getting the cell size right

Cell width is the image width divided by the number of columns, and cell height is the image height divided by the number of rows. A 512×256 sheet with 8 columns and 4 rows has 64×64 frames. Any image viewer will tell you the pixel dimensions.

The useful part is what happens when the division doesn’t come out whole. Say the sheet is 526 px wide with 8 columns: 526 ÷ 8 is 65.75, and no frame is 65.75 px wide. Whoever exported it put a 2 px gap between frames (8 × 64 + 7 × 2 = 526). In that case the frame is still 64, and the gap goes in a different field:

What the sheet hasSlice fieldValue
Frames of one sizePixel SizeThe frame itself, without any gap
A gap between framesPaddingThe gap in pixels
An empty border around the whole sheetOffsetThe border in pixels
Empty cells you want numbered anywayKeep Empty RectsTicked

If you made the sheet with our GIF to sprite sheet converter, skip the arithmetic: it prints the Grid By Cell Size width and height next to the download, and the spacing and margin you set there are the Padding and Offset here.

Some sheets can’t be described by any combination of these fields, because the frames aren’t the same size or weren’t placed on a grid at all. Ripped sheets and AI-generated ones are the usual suspects. You can drag every rectangle by hand in the Sprite Editor (the blue handles), but I wouldn’t. Fix the file instead: open it in the sprite sheet cutter, let auto-detect find the sprites, pad them to one size aligned by their feet, and download the frames as a ZIP. Then drop those PNGs into the sprite sheet maker to pack them back into an even grid. Both run in the browser and don’t upload the file. They can’t repaint anything, so a frame that was drawn cut off stays cut off.

Turn the slices into an animation

  1. Expand the texture in the Project window so the numbered sprites show.
  2. Click the first frame of one animation, then Shift-click the last, so only that animation’s frames are selected.
  3. Drag the selection into the Scene view or the Hierarchy.
  4. Unity asks where to save the Animation Clip. Name it after the action, such as hero_walk.

Unity creates a GameObject with a Sprite Renderer and an Animator, plus an Animator Controller with the new clip as its default state. Press Play and it runs.

It’ll probably run at the wrong speed. The frame rate lives in the clip’s Samples field in the Animation window (Window → Animation → Animation), and that field is hidden until you open the window’s three-dot menu and tick Show Sample Rate. Set Samples to the fps the animation was drawn at. A clip has one rate for all its frames, so if the source was a GIF that held some frames longer than others, those holds have to exist as repeated frames in the sheet.

Sheets for particles don’t need slicing

If the sheet is an explosion or a puff of smoke for a Particle System, leave the Sprite Editor alone. Enable the Texture Sheet Animation module, keep Mode on Grid, and set Tiles X to the number of columns and Y to the number of rows. Animation chooses between Whole Sheet and Single Row, and setting Time Mode to FPS plays it at a fixed rate instead of stretching it over the particle’s lifetime.

This module divides the texture evenly and has no padding or offset fields, so a sheet with gaps or a margin has to be repacked without them first. The module’s Sprites mode is the alternative: it takes sprites you’ve already sliced.

What goes wrong

There’s no Sprite Editor button

The button belongs to the 2D Sprite package. Projects made from the 2D template include it. Projects made from other templates may not. When it’s missing, the Inspector shows an Install 2D Sprite Package button where Open Sprite Editor would be. Click it, or install 2D Sprite from the Package Manager. If the button is there but Slice is greyed out, Sprite Mode is still on Single.

The sprites are blurry

Check three things in this order. Filter Mode should be Point (no filter), since Bilinear blends neighbouring pixels. Compression should be None, because the compressed formats smear small palettes. And Max Size has to cover the sheet, as described above. If the asset looks sharp in the Scene view but soft in the Game view, the import is fine and the camera is scaling by a fraction: add the Pixel Perfect Camera component from the 2D Pixel Perfect package and match its Asset Pixels Per Unit to your sprites.

Lines or slivers of the next frame at the edges

Frames that touch in the sheet are one texel apart, and any filtering or fractional scaling can sample across the boundary. Point filtering removes most of it, and turning off Generate Mipmap removes more. What’s left needs real empty pixels between frames. The Padding field in the Slice overlay doesn’t add any. It only tells Unity that gaps already exist in the image. So the gap has to be in the PNG: re-export with 1 or 2 px of spacing, then enter the same number as Padding. If you pack sprites into a Sprite Atlas, its own Padding setting (4 by default) does this for you.

The grid drifts further off with every column

A grid that fits the first frame and is a few pixels out by the tenth means the Pixel Size includes the gap, or leaves it out. Do the division from the section above and move the gap into Padding. A grid that’s off by the same amount everywhere needs Offset. And if the numbers are right on paper but the outlines still miss, look at Max Size again: you may be slicing a downscaled copy.

Frames numbered in the wrong order, or numbers missing

Grid slices are numbered in reading order, left to right starting with the top row. (The manual doesn’t say so; every guide I checked reports it.) Three things break the sequence you expected.

Empty cells are dropped unless Keep Empty Rects is ticked, so a 4×4 sheet with two blank cells yields 14 sprites, and everything after a blank moves down a number. Tick it when rows are separate animations of different lengths and you want row two to always start at the same index.

Slicing a second time doesn’t always start clean. The Method setting decides what happens to existing sprites: Delete Existing replaces them, while Smart and Safe keep old rectangles that overlap the new ones, names included. Use Delete Existing when you’re correcting a bad slice.

The third is the sheet itself. If it was packed top to bottom in columns, or the frames went in as walk_1, walk_10, walk_2, Unity is numbering them faithfully and the file is wrong. You can rename any sprite by selecting it in the Sprite Editor and editing Name, which is fine for two or three frames. For a whole sheet, cut it into frames with the cutter and repack: the maker sorts filenames naturally, so walk_2 comes before walk_10, and you can drag frames into place before exporting.

One last cause that looks like a slicing problem and isn’t: a filename such as ezgif.com-gif-to-sprite.png. In a Unity forum thread about a sheet that wouldn’t import, the suggested culprit was the .com in the middle of the name. Renaming the file costs nothing, so do it before you drag it in.