Beispiel #1
0
        public void Cubemap(Cubemap texture)
        {
            var resourceName           = EvaluateCubemapName(texture);
            var assetGuid              = texture.GetKey();
            var sourceFileTimestampUtc = ExportUtils.GetLastWriteTimeUtc(texture);

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

            if (!EnsureReadableTexture(texture))
            {
                return;
            }

            using (var writer =
                       _engine.TryCreateXml(assetGuid, resourceName, sourceFileTimestampUtc))
            {
                if (writer != null)
                {
                    WriteCubemap(texture, resourceName, writer);
                }
            }
        }
Beispiel #2
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;
            }
        }