Unity3d的Resource、AssetBundle与手游动态更新的报告,在这里分享一下,希望能够对各位用Unity的朋友有些许帮助。目录:1.Unity的资源数据加载2.Resource、StreamingAsset文件夹,安装后的路径(Android,iOS)3.Unity在打包和安装的时候怎么处理persistentDataPath4.Unity的Android和IOS上相关的目录结构5.Unity常用目录对应的Android && iOS平台地址分割一下目录与主体。。。1.Unity的资源数据加载 - Resources、AssetBundle、StreamingAsset、PersistentDataPathResources- 打包集成到.asset文件里面及引用的资源as后se一个文件里面面- 主线程加载- 想要动态更新资源则不考虑AssetBundle- unity定义的二进制文件类型- 用WWW类下载StreamingAssets- 可读不可写- 内容限制 - 无- 只能用WWW类下载PersistentDataPath目录下- 可读可写- 内容限制 - 无- 清除手机缓存文件会一并清理这里的东西- 随意弄,可作为本地目录让WWW下载、也可以自己用FileInfo乱整2.Resource、StreamingAsset文件夹,安装后的路径(Android,iOS)StreamingAsset- iOS : Application.dataPath /Raw- Android : jar:file:// Application.dataPath !/assets/Resources- 打包成一个Asset文件3.Unity在打包和安装的时候怎么处理PersistentDataPath- PersistentDataPath- 就是com.**.**/files 的路径而已(打过APK包的应该都明白吧)4.Unity的Android和IOS上相关的目录结构Android:- assets 游戏内容相关的都在这里了- lib JNI相关的东西- META-INF Java包跟rar包的区别- res 图标之类的- AndroidManifest.xml Android配置文件- classes.dex Java虚拟机runtime的东西- resources.arsc Java编译后的二进制文件IOS:- level0/level1… Scene- sharedassets0/shaedassets1/… Scene相关的东西- Managed 脚本编译后的dll- resources.assets Resources里面的东西- Raw StreamingAssets里面的东西5. Unity常用目录对应的Android && iOS平台地址IOS:Application.dataPath : Application/xxxxx/xxx.app/DataApplication.streamingAssetsPath : Application/xxxxx/xxx.app/Data/RawApplication.persistentDataPath : Application/xxxxx/DocumentsApplication.temporaryCachePath : Application/xxxxx/Library/CachesAndroid:Application.dataPath : /data/app/xxx.xxx.xxx.apkApplication.streamingAssetsPath : jar:file:///data/app/xxx.xxx.xxx.apk/!/assetsApplication.persistentDataPath : /data/data/xxx.xxx.xxx/files
Application.temporaryCachePath : /data/data/xxx.xxx.xxx/cache
在看到这篇文章的使用,使用了Unity3D 5.x 版本读取二进制文件,官方给出的解释方案为:
在使用Application.streamingAssetsPath部分的时候本地读取使用io进行读取,服务器加载使用www加载:
代码样例:
IEnumeratorLoadFile() {
stringresult;
if(filePath.Contains("://")) {
WWWwww=newWWW(filePath);
yieldreturnwww;
result=www.text;
}else
result=System.IO.File.ReadAllText(filePath);
Debug.Log("result:"result);
}
void start()
{
StartCoroutine(Example());
}
/