在Unity3d中导出.tga或.png图像文件到磁盘



有任何方法用代码导出。png或。tga文件到本地磁盘在Unity?我需要编写一个转换器来加载资源包并将它们转换为原始的源图像文件。我需要创建那些文件,以一种任何人都能打开的方式比如用Photoshop。知道怎么做吗?

谢谢。大卫。

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

您可以使用Encode To TGA插件将图像保存为TGA格式:http://u3d.as/rWt

最新更新