使用Application.persistentDataPath将Assetbundle缓存到本地
来源:互联网 发布:淘宝购物车打不开 编辑:程序博客网 时间:2024/06/05 22:34
IEnumerator loadAndSaveAsset(string url) //下载网络模型并缓存到本地 { WWW w = new WWW(url); yield return w; if (w.isDone) { byte[] model = w.bytes; int length = model.Length; //文件流信息 //StreamWriter sw; Stream sw; FileInfo t = new FileInfo(Application.persistentDataPath + "//" + "Model.assetbundle"); if (!t.Exists) { //如果此文件不存在则创建 sw = t.Create(); } else { //如果此文件存在则打开 sw = t.OpenWrite(); } sw.Write(model, 0, length); //关闭流 sw.Close(); //销毁流 sw.Dispose(); } }
从本地读取模型文件:
//读取本地的模型文件 IEnumerator LoadModelFromLocal() { string s = null; #if UNITY_ANDROID s = "jar:file://" + Application.persistentDataPath + "/" + "Model.assetbundle"; #elif UNITY_IPHONE s = path+"/"+name; #elif UNITY_STANDALONE_WIN || UNITY_EDITOR s = "file://"+path+"/"+name; #endif WWW w = new WWW(s); yield return w; if (w.isDone) { Instantiate(w.assetBundle.mainAsset); } }
删除文件
void DeleteFile(string path, string name) { File.Delete(path + "//" + name); }
FR:海涛高软(hunk Xu)
阅读全文
0 0
- 使用Application.persistentDataPath将Assetbundle缓存到本地
- Application.persistentDataPath保存字符串到本地
- Application.persistentDataPath
- Application.persistentDataPath
- Application.persistentDataPath
- unity 安卓 如何读取 Application.persistentDataPath这个路径下面的assetbundle文件
- android 将bitmap缓存到本地
- Unity Application.persistentDataPath 空值
- Unity Application.persistentDataPath 为空
- 坑爹的Application.persistentDataPath
- 使用python将远程图片下载到本地
- Unity 如何删除本地指定的AssetBundle缓存?
- 使用diskLruCache缓存数据到本地(个人笔记)
- ImageLoader超简单使用并缓存到本地SD卡
- 将图片下载到本地
- 本地缓存的使用
- 使用Git将本地代码上传到GitHub
- Git的使用,将本地代码git到GitHub
- transfer learning与finetuning区别
- C程序设计语言(三)指针与数组
- 欢迎使用CSDN-markdown编辑器
- 每天五分钟linux(15)-tail
- 小明历险记:规则引擎drools教程一
- 使用Application.persistentDataPath将Assetbundle缓存到本地
- JavaScript(一)部分数组操作的方法等
- PHP将XML转换成数组/对象
- 突破SafeSEH机制之二——利用未启用SafeSEH模块绕过SafeSEH
- django 导入导出
- linux高频命令
- Python3学习(6)--切片【Slice】
- 巧妙地解决缓冲区覆盖问题方法二
- hdu-2063-过山车(匈牙利算法)