- Home /
Question by
Krobill · Jan 21, 2011 at 12:52 PM ·
texturebackgroundatlas
How to change background color of on an Atlas ?
Obviously the packTextures method doesn't allow to choose the default background color for an atlas, but if anyone as a simple method to do it that would help ^^
Comment
Did you find a solution to your problem? I have the same problem...
Answer by ludo6577 · Nov 17, 2016 at 10:41 PM
Ok i finally found a solution to your (old) problem. I colorize the atlas after its creation but only the part that have alpha set to 0f
like this:
var textureSize = 4096;
Texture2D atlas = new Texture2D(textureSize, textureSize);
var rects = atlas.PackTextures(atlasTextures.ToArray(), 10, textureSize);
var marge = 0.001f;
for (var i = 0; i < atlas.width; i++)
{
for (var j = 0; j < atlas.height; j++)
{
var pixel = atlas.GetPixel(i, j);
if (pixel == new Color(pixel.r, pixel.g, pixel.b, 0f))
atlas.SetPixel(i, j, Color.white);
}
}
atlas.Apply();