2D Tile Gap Fixing Tool is a Unity Editor extension that eliminates gaps between tiles in 2D tilemaps. It reformats tilesheets so that each tile is surrounded by a ring of pixels matching the tile's edge colors, preventing visual artifacts caused by floating-point rounding errors.
ℹ️ Note: This is an updated and maintained version of the original Unity Asset Store tool (now unavailable).
Updated version available on GitHub
⚠️ Warning: This tool modifies image files in your project. Always back up your project before using it.
- The Problem
- The Solution
- Features
- Getting Started
- How to Use
- Settings Explained
- Why Use This Instead of Sprite Atlas?
- Known Issues & Limitations
- Contact
- Version History
- License
When using the Unity 2D tilemap system, gaps or incorrectly colored pixels can appear between tiles. This can happen in the Scene view, Game view, or in the released product.
The underlying problem is caused by rounding errors due to the nature of floating-point operations. When a gap occurs, Unity tries to fill it using the pixels surrounding the tile in the original tilesheet. This usually means transparent pixels, pixels outside the tilesheet (which count as transparent), or pixels from adjacent tiles — resulting in unwanted visual artifacts.
This tool reformats tilesheets such that each tile is surrounded by a rectangle of pixels, each taking their color from the pixel at the edge of the original tile. This ensures that when Unity samples outside the tile boundaries, it gets the correct edge color instead of transparent or adjacent tile pixels.
⠀
- Automatic Tile Processing: Surrounds each tile with edge-matching pixels to eliminate gaps.
- Visual Preview: Preview sliced tiles before saving to verify correct alignment.
- Backup Support: Option to create a backup of the original file before conversion.
- Flexible Output: Choose to overwrite the original file or create a new converted file.
- PNG Support: Works with PNG image files.
- Example Scene: Includes a test scene with sample tilesheets to practice using the tool.
- Install: Import this package into your Unity project. Ensure the Editor scripts are in a folder named
Editor. - Open: From the menu, select Window > 2D > Tilesheet converter.
- Dock (optional): Dock the window or resize it to allow enough vertical space and width for the controls.
- Backup your project using version control (Git), Unity Collaboration, or by copying your project folder.
- Drag your tilesheet PNG file into the "Drop image asset" field.
- Enter the correct values for Tile Width, Tile Height, Offset, and Padding (matching your Sprite Editor settings).
- Click "Slice" to preview the tiles (non-destructive).
- Verify the tiles in the preview area. Use the "Tile thumb size" slider to zoom in/out.
- Adjust settings if tiles appear misaligned, then click "Slice" again.
- Configure output options:
- Check "Make backup" to create a copy of the original file.
- Check "Overwrite original" to replace the original file, or uncheck to create a new file.
- Click "Overwrite original file" or "Save updated file" to perform the conversion.
- Refresh the Project window (right-click > Refresh) to see file changes.
- Re-slice in Sprite Editor if needed (when offset/padding changed or a new file was created).
| Setting | Description |
|---|---|
| Tile Width | The width of each tile in pixels (without offset or padding). |
| Tile Height | The height of each tile in pixels (without offset or padding). |
| Offset X | Number of empty pixels at the left edge of the tilesheet. |
| Offset Y | Number of empty pixels at the top edge of the tilesheet. |
| Padding X | Horizontal gap in pixels between tiles (not around each tile). |
| Padding Y | Vertical gap in pixels between tiles (not around each tile). |
Note: A padding of 2 means there are 2 pixels between tiles, not a 2-pixel gap around each tile.
Unity's Sprite Atlas feature can also solve tile gap issues by packing sprites with padding. However, this tool offers a significant advantage when working with version control systems (Git, SVN, Plastic SCM / Unity Version Control, etc.):
- Sprite Atlas files are unstable: Unity frequently modifies Sprite Atlas assets (
.spriteatlasand their cached textures) even when no actual changes were made. This creates unnecessary commits, clutters your version history, and can cause merge conflicts. - This tool produces stable files: The converted tilesheets are standard PNG files that only change when you explicitly modify them. No phantom changes, no unexpected diffs.
- Better for collaboration: Team members won't see constant atlas modifications that weren't intentional, making code reviews and history tracking much cleaner.
- PNG Only: Only PNG files are supported due to texture import limitations in Unity.
- Sprite Editor Update: If the tilesheet is expanded (due to insufficient original padding/offset), you will need to update the slice settings in the Sprite Editor manually.
- File Overwrite: The tool saves files to your project and may overwrite existing files. Always backup first.
Ben Dunkley (Original Author)
Chonky Pixel
ben@chemica.co.uk
Jonathan Tremblay (Updated Version)
Teacher, Cégep de Saint-Jérôme
jtrembla@cstj.qc.ca
- 1.1.0
- Updated by Jonathan Tremblay:
- Fixed obsolete API usage (AssetDatabase.GetAssetPath) and logical error in ValidateMetrics.
- Added safety checks for null assets or when no tiles are detected.
- Renamed methods to follow C# PascalCase convention.
- Converted to a UPM package structure.
- Updated by Jonathan Tremblay:
- 1.0.0
- Original release by Ben Dunkley (Chonky Pixel).
- Original tool created by Ben Dunkley (Chonky Pixel).
- Originally distributed under Unity Asset Store terms.