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支持中文與本地文件的讀取寫入

相關文章
相關標籤/搜索