unity 各平台本地文件的读取目录

在win上,将配置文件放在了 Application.dataPath 目录下,编辑状态下,测试经过。发布为exe后,读取失败。后来将配置文件放到生成的_data文件下,经过。html

固然想到之后发布到其余平台,在移动端下 Application.persistentDataPath  才是移动端可用的保存生成文件的地方,放到resource中打包后不能够更改了,放到Application .dataPath中移动端是没有访问权限的。须要修改的文件建议放在Application.persistentDataPath这个目录下,不管是安卓仍是IOS这个目录都是好用的。
这样的话,大家的文件用户能够显示看到。
android

 

Application.dataPath
 Unity Editor:<path tp project folder>/Assets
Mac player:<path to player app bundle>/Contents
iPhone player:<path to player app bundle>/<AppName.app>/Data
Win player:<path to executablename_Data folder>
Web player:The absolute url to the player data file folder (without the actual data file name)

Application .persistentDataPath
app

用宏定义
#if UNITY_IPHONE
Application.dataPath+''/iphone/';
#endif
#if UNITY_ANDROID
Application.dataPath+''/android/';
#endifiphone

 

Unity3D 游戏引擎之IOS Android支持中文与本地文件的读取写入

相关文章
相关标签/搜索