ArgumentException: Atlas "foo" (2048x2048) can't fit sprite "texture2" (3840x1080)
The exception carries both numbers you need, and most people read neither. Atlas "foo" (2048x2048) is the texture the packer was building. sprite "texture2" (3840x1080) is the rectangle it was trying to place. One axis of the sprite is 3840; the atlas side is 2048. Nothing is going to fit into that.
That is the whole failure. It is not "the atlas is full" and it is not "too many sprites". A single sprite is larger than the atlas can ever be, so the packer gives up and throws.
I hit this on a UI-heavy 2D project where a 3840x1080 backdrop had been dragged into the same atlas as buttons and icons. Unity's answer was an exception in the console and a pink atlas in the player.
Where the two numbers come from
The (2048x2048) half is read from the Master Atlas texture size that is active for the current platform. In the Sprite Atlas inspector that is Max Texture Size, and it is a per-platform setting: a Default value plus overrides for Android, iOS, Standalone and the rest. On a fresh Sprite Atlas it is 2048.
This gives you a free diagnostic. If the number in the exception does not match what you set in the inspector, a platform override is winning, or you are looking at a different atlas than the one being packed. I have burned an hour on that second case more than once: the exception named UIAtlas while I kept editing UISpriteAtlas.
The (3840x1080) half is the sprite rectangle as the packer sees it, in texture pixels after import. If the source texture is imported with a Max Size of 512, this number is already 512, not the original width. That matters when the number looks smaller than the PNG on disk.
What "fit" actually means here
The packer takes every object in Objects for Packing, tries to arrange their rectangles inside one texture of at most Max Texture Size, and writes the result. It does not scale a sprite down to make it fit. There is no automatic fallback to "just use a bigger atlas". If one rectangle is wider or taller than the limit, packing cannot succeed for that atlas, and you get the ArgumentException.
You will find a lot of advice telling you to implement IPackerPolicy and raise the size that way. That advice belongs to the Legacy Sprite Packer, which Unity removed in 2020.1. The exception above comes from the Sprite Atlas packer, which has no policy hook at all. Following that answer wastes an afternoon and changes nothing.
Raising Max Texture Size to 4096 fixes the symptom
Set Max Texture Size to 4096 and the 3840 side fits. The atlas rebuilds, the sprite appears, everyone is happy until the build gets bigger.
A 4096x4096 RGBA atlas is 64 MB uncompressed before mipmaps. On desktop that may be acceptable. On a mid-range Android device it is a hard no, and the atlas slot is now spending all of its budget on one backdrop that never needed to be in an atlas.
There is also the POT detail. A 4096x2048 atlas is not what you get. Once the packer needs 3840 on one axis it rounds up to 4096 on both, so a 3840x1080 image that was supposed to be 4 MB of VRAM now occupies a full square page.
The question to ask first: does this sprite belong in an atlas
Sprite atlases exist to batch. Many small sprites sharing one texture and one material can be drawn with far fewer state changes than the same sprites as separate textures. That is the win.
A 3840x1080 full-screen backdrop gets none of that win. It is drawn once, usually behind everything, and it is the largest thing on screen. Putting it in the atlas makes the atlas bigger, evicts smaller sprites into a second page, and can turn one draw call into two.
My rule after this bug: if a sprite is bigger than a quarter of the screen, it does not go in a gameplay atlas. Backdrops, full-screen gradients, large parallax layers and dialogue CG all get their own texture. Atlases keep buttons, icons, character frames, particles and fonts.
For a wide backdrop, draw it with a SpriteRenderer in Tiled draw mode, a 9-sliced UI image, or a RawImage with a texture. Those all avoid the packing step entirely.
Find the offender before touching settings
If the sprite is not obvious (the exception name is often a texture asset name, not the sprite you renamed), select the atlas and run this in an Editor script. It lists every sprite in the atlas that cannot fit.
using UnityEditor; using UnityEngine; using UnityEngine.U2D; public static class AtlasFitAudit { [MenuItem("Tools/Atlas Fit Audit")] static void Run() { var atlas = Selection.activeObject as SpriteAtlas; if (atlas == null) { Debug.LogError("Select a Sprite Atlas asset first."); return; } // Match this to the Max Texture Size that is active for your build target. const int maxSize = 2048; foreach (var packable in atlas.GetPackables()) { string path = AssetDatabase.GetAssetPath(packable); if (string.IsNullOrEmpty(path)) continue; foreach (var asset in AssetDatabase.LoadAllAssetsAtPath(path)) { if (!(asset is Sprite sprite)) continue; var r = sprite.rect; if (r.width > maxSize || r.height > maxSize) Debug.LogWarning($"{sprite.name} in {path}: {r.width}x{r.height} > {maxSize}", sprite); } } } } sprite.rect is the imported rectangle, so it already reflects the texture's Max Size and any custom rect you set in the Sprite Editor. Padding and multiple atlases are not modelled, so treat the output as an upper bound. It is enough to find the one asset that cannot possibly fit.
If the audit prints nothing and the exception persists, check the other atlases in the project. The same texture can be listed in two atlases with different Max Texture Size values, and the smaller one throws.
Why it looks random between Editor and device
Packing happens on import with the Default settings and again per platform at build time. Picture this:
- Default Max Texture Size: 2048
- Android override: 1024
- One sprite at 1500x300
In the Editor everything packs. Build for Android and the packer throws Atlas "UI" (1024x1024) can't fit sprite "banner" (1500x300). Same project, same assets, different number in the parentheses. That is the platform override doing its job, not a corrupt Library folder.
Variant atlases add a second twist. A variant with scale 0.5 packs the sprites at half size, so its rectangles shrink, but the variant has its own Max Texture Size. A variant limited to 1024 with a 0.5 scale still needs the source sprite under 2048 to land under 1024.
Fixes, ordered by how often they are the right one
- Remove the sprite from the atlas. For a backdrop this is almost always correct. Drag it out of Objects for Packing and give it its own texture.
- Split the atlas by purpose. UI, characters and effects rarely share a screen region or a lifetime. Three 2048 atlases usually beat one 4096.
- Lower the texture's import Max Size. Only if the image genuinely does not need the resolution. This changes the number the packer sees.
- Raise Max Texture Size for the platform. Legitimate for a hero asset on desktop. Check the target GPU's guaranteed limit and count the VRAM.
- Draw the backdrop tiled or 9-sliced. No packing involved, no size limit, less memory than one giant page.
- Audit the second atlas. If two atlases reference the texture, fix the small one too, or remove the texture from it.
One more thing about the name in the message
Unity prints the atlas asset name, not the file path, and it prints the sprite's texture name in the second pair of quotes. When your project has Atlas, Atlas 1 and Atlas Variant, the message is not much help. The audit script above prints the asset path for each offender, which is usually faster than searching the Project window.
The error is one of the few Unity asset-pipeline exceptions that tells you the exact fix in the text: compare the two numbers. Everything after that is a decision about whether that sprite deserves to be in an atlas at all.
If you want the same check without opening the Editor, there is an offline Windows tool that reads an atlas page plus its JSON and reports frames outside the page or duplicated across pages, and writes a CSV you can diff between builds. It is free and needs no email: download the atlas fixer.
The full write-up for this error, with the verbatim message and the source thread, is here: Unity: Atlas can't fit sprite. The other 32 Unity atlas and sprite errors I collected are indexed by engine: Unity error index.