/// <summary>
/// 图片保存
/// </summary>
/// <param name="tex">Tex.</param>
private void ImageSaveLocal(Texture tex){
string path = null;
#if UNITY_ANDROID
path=Application.persistentDataPath+"/"+pic_fileName;
#elif UNITY_IPHONE
path=Application.persistentDataPath+"/"+pic_fileName;
#elif UNITY_EDITOR
path=Application.dataPath+"/"+pic_fileName;
#endif
Texture2D saveImageTex = tex as Texture2D;
FileStream newFs = new FileStream (path,FileMode.Create,FileAccess.Write);
byte[] bytes = saveImageTex.EncodeToJPG ();
newFs.Write (bytes,0,bytes.Length);
newFs.Close ();
newFs.Dispose ();
}
Unity 图片保存 简单使用
最新推荐文章于 2023-12-09 13:35:21 发布