Exemplo n.º 1
0
        public static Texture2D Convert(Texture2D texture, glTFTextureTypes textureType, ColorConversion colorConversion, Material convertMaterial)
        {
            var copyTexture = TextureItem.CopyTexture(texture, TextureIO.GetColorSpace(textureType), convertMaterial);

            if (colorConversion != null)
            {
                copyTexture.SetPixels32(copyTexture.GetPixels32().Select(x => colorConversion(x)).ToArray());
                copyTexture.Apply();
            }
            copyTexture.name = texture.name;
            return(copyTexture);
        }
Exemplo n.º 2
0
        public int CopyAndGetIndex(Texture texture, RenderTextureReadWrite readWrite)
        {
            if (texture == null)
            {
                return(-1);
            }

            var index = m_textures.IndexOf(texture);

            if (index == -1)
            {
                // ありえない?
                return(-1);
            }

            // ToDo: may already exists
            m_exportTextures[index] = TextureItem.CopyTexture(texture, readWrite, null);

            return(index);
        }
Exemplo n.º 3
0
        static BytesWithMime GetBytesWithMime(Texture texture, glTFTextureTypes textureType)
        {
#if UNITY_EDITOR
            var path = UnityPath.FromAsset(texture);
            if (path.IsUnderAssetsFolder)
            {
                if (path.Extension == ".png")
                {
                    return(new BytesWithMime
                    {
                        Bytes = System.IO.File.ReadAllBytes(path.FullPath),
                        Mime = "image/png",
                    });
                }
            }
#endif

            return(new BytesWithMime
            {
                Bytes = TextureItem.CopyTexture(texture, TextureIO.GetColorSpace(textureType), null).EncodeToPNG(),
                Mime = "image/png",
            });
        }