Skip to content

Commit c28902d

Browse files
committed
fix compression texture export error
1 parent fc0bb99 commit c28902d

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

Export/filter/TextureFile.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,34 @@ public override void SaveFile(Dictionary<string, FileData> exportFiles)
357357
byte[] bytes = this._texture.EncodeToPNG();
358358
File.WriteAllBytes(this.outPath, bytes);
359359
}
360+
else if (this._format == 3)
361+
{
362+
string path = AssetDatabase.GetAssetPath(this._texture.GetInstanceID());
363+
TextureImporter import = AssetImporter.GetAtPath(path) as TextureImporter;
364+
if (import == null)
365+
{
366+
Debug.LogError(LOGHEAD + path + " can't export You should check the texture file format");
367+
return;
368+
}
369+
else
370+
{
371+
import.textureType = TextureImporterType.Default;
372+
import.isReadable = true;
373+
import.textureCompression = TextureImporterCompression.Uncompressed;
374+
TextureImporterPlatformSettings pc = import.GetPlatformTextureSettings("Standalone");
375+
pc.overridden = true;
376+
pc.format = TextureImporterFormat.RGBA32;
377+
import.SetPlatformTextureSettings(pc);
378+
AssetDatabase.ImportAsset(path);
379+
380+
byte[] bytes = this._texture.EncodeToPNG();
381+
File.WriteAllBytes(this.outPath, bytes);
382+
}
383+
}
360384
else
361385
{
362386
Debug.LogError("Texture format UnSupport export!!!");
363387
}
364388
}
365389
}
366-
367-
368390
}

0 commit comments

Comments
 (0)