ActiveTextureManagement.ColorExtensions.bytes C# (CSharp) Метод

bytes() публичный статический Метод

public static bytes ( this texture, int mipmapLevel, bool hasAlpha = true ) : byte[]
texture this
mipmapLevel int
hasAlpha bool
Результат byte[]
        public static byte[] bytes(this Texture2D texture, int mipmapLevel, bool hasAlpha = true)
        {
            Color32[] colors = texture.GetPixels32(mipmapLevel);
            byte[] array;
            if (hasAlpha)
            {
                array = new byte[colors.Length * 4];
                for (int i = 0; i < colors.Length; i++)
                {
                    array[(i * 4)] = colors[i].r;
                    array[(i * 4) + 1] = colors[i].g;
                    array[(i * 4) + 2] = colors[i].b;
                    array[(i * 4) + 3] = colors[i].a;
                }
            }
            else
            {
                array = new byte[colors.Length * 3];
                for (int i = 0; i < colors.Length; i++)
                {
                    array[(i * 3)] = colors[i].r;
                    array[(i * 3) + 1] = colors[i].g;
                    array[(i * 3) + 2] = colors[i].b;
                }
            }
            return array;
        }
ColorExtensions