public static Texture2D MergeSkin(params Clothing[] skin)
{
int a = 0;
Texture2D newCloth = new Texture2D(skin[0].texture.width, skin[0].texture.height);
foreach (Clothing cloth in skin)
{
if (newCloth.width != cloth.texture.width || newCloth.height != cloth.texture.height)
throw new System.Exception("Merging texture error, not same size : [" + skin[0].texture.name + " | " + cloth.texture.name + "]");
for (int i = 0; i < newCloth.width; i++)
for (int j = 0; j < newCloth.height; j++)
{
Color pixel = cloth.texture.GetPixel(i, j);
if (pixel.a != 0)
newCloth.SetPixel(i, j, pixel);
}
a++;
}
newCloth.Apply();
return newCloth;
}