4 Commits
Author SHA1 Message Date
max 41e78763bf Merge pull request #13 from yany79/clear-atlas-texture-before-combining
Bugfix: Clear the atlas texture before combining quads.
2026-09-14 11:37:04 +02:00
max df397717a4 Merge pull request #14 from yany79/guard-texture-reinitialize-for-older-unity
Use Texture2D.Reinitialize on Unity 2021.2 and newer.
2026-09-14 11:36:31 +02:00
Juke 6598d8243b Use Texture2D.Reinitialize on Unity 2021.2 and newer. 2026-09-09 16:54:44 +02:00
Juke 3ad2a3cf67 Bugfix: Clear the atlas texture before combining quads. 2026-09-09 16:46:21 +02:00
2 changed files with 11 additions and 0 deletions

No files matched your search

@@ -521,6 +521,13 @@ namespace MA_TextureAtlasserPro
name = atlas.name + "_" + atlas.textureGroupRegistration[i].name name = atlas.name + "_" + atlas.textureGroupRegistration[i].name
}; };
//A new Texture2D is uninitialised, and MA_Combine2D only writes inside each quad's
//guiRect, so every texel no quad covers keeps whatever was left in the buffer. That
//garbage is opaque enough to survive an alpha cutoff and bleeds into the quads
//through the mip chain, so clear the atlas to transparent black before combining.
newTexture.SetPixels32(new Color32[newTexture.width * newTexture.height]);
newTexture.Apply();
foreach (MA_TextureAtlasserProQuad q in atlas.textureQuads) foreach (MA_TextureAtlasserProQuad q in atlas.textureQuads)
{ {
if (q.textureGroups != null && q.textureGroups[i].texture != null) if (q.textureGroups != null && q.textureGroups[i].texture != null)
@@ -122,7 +122,11 @@ namespace MA_Texture
} }
#if UNITY_2021_2_OR_NEWER
texture.Reinitialize(newWidth, newHeight);
#else
texture.Resize(newWidth, newHeight); texture.Resize(newWidth, newHeight);
#endif
texture.SetPixels(newColors); texture.SetPixels(newColors);
texture.Apply(); texture.Apply();