Esempio n. 1
0
        public static SimpleGif.Data.Texture2D ConvertTexture(Texture2D source)
        {
            var texture = new SimpleGif.Data.Texture2D(source.width, source.height);
            var pixels  = source.GetPixels32().Select(i => new SimpleGif.Data.Color32(i.r, i.g, i.b, i.a)).ToArray();

            texture.SetPixels32(pixels);
            texture.Apply();

            return(texture);
        }
Esempio n. 2
0
        public static Texture2D ConvertTexture(SimpleGif.Data.Texture2D source)
        {
            var pixels       = new Color32[source.width * source.height];
            var pixels32     = source.GetPixels32();
            var transparency = false;

            for (var i = 0; i < pixels.Length; i++)
            {
                pixels[i] = new Color32(pixels32[i].r, pixels32[i].g, pixels32[i].b, pixels32[i].a);

                if (!transparency && pixels[i].a == 0)
                {
                    transparency = true;
                }
            }

            var texture = new Texture2D(source.width, source.height, transparency ? TextureFormat.RGBA32 : TextureFormat.RGB24, true);

            texture.SetPixels32(pixels);
            texture.Apply();

            return(texture);
        }