示例#1
0
        protected override void OnUpdate()
        {
            Entities.ForEach((UnityEngine.Texture2D texture) =>
            {
                var writer = TryCreateAssetExportWriter(texture);
                if (writer != null)
                {
                    var parameters = GetTextureCompressionParams(texture);
                    switch (parameters.FormatType)
                    {
                    case TextureFormatType.WebP:
                    default:
                        Texture2DExportUtils.EncodeWebP(writer, texture, parameters.Lossless, parameters.CompressionQuality);
                        break;

                    case TextureFormatType.PNG:
                        Texture2DExportUtils.ExportPng(writer, texture);
                        break;
                    }
                }
                else
                {
                    throw new Exception($"Failed to retrieve FileInfo for texture: {texture.name}");
                }
            });
        }
示例#2
0
        protected override void OnUpdate()
        {
            Entities.ForEach((UnityEngine.Texture2D texture) =>
            {
                var entity               = GetPrimaryEntity(texture);
                string textPath          = AssetDatabase.GetAssetPath(texture);
                TextureImporter importer = (TextureImporter)TextureImporter.GetAtPath(textPath);
                TextureImporterSettings textureImporterSettings = new TextureImporterSettings();
                importer.ReadTextureSettings(textureImporterSettings);
                DstEntityManager.AddComponentData(entity, new Image2D()
                {
                    imagePixelWidth  = texture.width,
                    imagePixelHeight = texture.height,
                    status           = ImageStatus.Invalid,
                    flags            = Texture2DExportUtils.GetTextureFlags(textureImporterSettings, texture)
                });

                DstEntityManager.AddComponent <Image2DLoadFromFile>(entity);

                var exportGuid = GetGuidForAssetExport(texture);

                DstEntityManager.AddComponentData(entity, new Image2DLoadFromFileGuids()
                {
                    imageAsset = exportGuid,
                    maskAsset  = Guid.Empty
                });
            });
        }
示例#3
0
 protected override void OnUpdate()
 {
     Entities.ForEach((UnityEngine.Texture2D texture) =>
     {
         using (var writer = TryCreateAssetExportWriter(texture))
         {
             if (writer != null)
             {
                 Texture2DExportUtils.ExportPng(writer, texture);
             }
         }
     });
 }