Export .tga or .png image file to disk in Unity3d

4.9k Views Asked by At

There is any way with code to export a .png or .tga file to local disk in Unity? I need to write a converter that loads asset bundles and converts them to the original source image files. I need to create those files, in a way that anyone could open them with Photoshop, for instance. Any idea about how to do it?

Thanks. David

2

There are 2 best solutions below

0
On
void Save(Texture2D texture)
{
    var bytes = texture.EncodeToPNG();
    File.WriteAllBytes(EditorUtility.SaveFilePanel("Save PNG", Application.dataPath + "/../", "Font", "png"), bytes);
}
0
On

You can save image in TGA format using Encode To TGA plugin: http://u3d.as/rWt