Beispiel #1
0
        private void CopyTextureAndSaveAs(Texture texture)
        {
            var outputAssetName        = EvaluateTextureName(texture);
            var sourceFileTimestampUtc = ExportUtils.GetLastWriteTimeUtc(texture);
            var assetGuid = texture.GetKey();

            if (_engine.IsUpToDate(assetGuid, outputAssetName, sourceFileTimestampUtc))
            {
                return;
            }

            var tImporter      = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(texture)) as TextureImporter;
            var texType        = tImporter?.textureType ?? TextureImporterType.Default;
            var textureOptions = ExportUtils.GetTextureOptions(texture);

            switch (texType)
            {
            case TextureImporterType.NormalMap:
                new TextureProcessor().ProcessAndSaveTexture(texture, "Hidden/UnityToCustomEngineExporter/Urho3D/DecodeNormalMap", _engine.GetTargetFilePath(outputAssetName), true);
                break;

            default:
                new TextureProcessor().ProcessAndSaveTexture(texture, "Hidden/UnityToCustomEngineExporter/Urho3D/Copy", _engine.GetTargetFilePath(outputAssetName), textureOptions.textureImporterFormat != TextureImporterFormat.DXT1);
                WriteOptions(assetGuid, outputAssetName, sourceFileTimestampUtc, textureOptions.WithSRGB(true));
                break;
            }
        }
        public void Cubemap(Cubemap texture)
        {
            if (!EnsureReadableTexture(texture))
            {
                return;
            }

            var resourceName = EvaluateCubemapName(texture);

            using (var writer =
                       _engine.TryCreateXml(texture.GetKey(), resourceName, ExportUtils.GetLastWriteTimeUtc(texture)))
            {
                if (writer != null)
                {
                    var ddsName = resourceName.Replace(".xml", ".dds");
                    var srgb    = true;
                    DDS.SaveAsRgbaDds(texture, _engine.GetTargetFilePath(ddsName), srgb);
                    writer.WriteStartElement("cubemap");
                    writer.WriteWhitespace(Environment.NewLine);
                    writer.WriteStartElement("srgb");
                    writer.WriteAttributeString("enable", srgb ? "true" : "false");
                    writer.WriteEndElement();
                    writer.WriteStartElement("image");
                    writer.WriteAttributeString("name", Path.GetFileName(ddsName));
                    writer.WriteEndElement();
                    writer.WriteWhitespace(Environment.NewLine);
                    writer.WriteEndElement();
                }
            }
        }
Beispiel #3
0
        private void WriteCubemap(Cubemap texture, string resourceName, XmlWriter writer)
        {
            var ddsName = resourceName.Replace(".xml", ".dds");
            var srgb    = true;

            DDS.SaveAsRgbaDds(texture, _engine.GetTargetFilePath(ddsName), srgb);
            writer.WriteStartElement("cubemap");
            writer.WriteWhitespace(Environment.NewLine);
            writer.WriteStartElement("srgb");
            writer.WriteAttributeString("enable", srgb ? "true" : "false");
            writer.WriteEndElement();
            writer.WriteStartElement("image");
            writer.WriteAttributeString("name", Path.GetFileName(ddsName));
            writer.WriteEndElement();
            writer.WriteWhitespace(Environment.NewLine);
            writer.WriteEndElement();
        }