您的位置:首页 > 移动开发 > Unity3D

Unity 图片保存 简单使用

2017-04-01 10:31 357 查看
/// <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
相关文章推荐