我必須在iOS設備上爲Unity遊戲本地保存一些數據。 Unity提供Directory.createDirectory在iOS中創建文件而不是目錄
Application.persistentDataPath
獲取公共目錄保存數據。並在控制檯上打印顯示這個返回iOS的路徑是正確的,即/ Users/userName/Library/Developer/CoreSimulator/Devices/******** - **** - **** - *** * - ************ /數據/集裝箱/數據/應用/ ************ - ******** - *** *********/Documents/
所以一個函數返回路徑和其他檢查目錄是否存在,如果不是,它應該創建一個目錄,但它創建沒有任何擴展名的文件。這裏是我的代碼
void savePose(Pose pose){
if (!Directory.Exists(PoseManager.poseDirectoryPath())){
Directory.CreateDirectory(PoseManager.poseDirectoryPath());
//Above line creates a file
//by the name of "SavedPoses" without any extension
}
// rest of the code goes here
}
static string poseDirectoryPath() {
return Path.Combine(Application.persistentDataPath,"SavedPoses");
}
** 1。**這是我的原始代碼,在檢查其他問題後更改了它。正如我所說的,在兩種情況下(原始字符串和Path.Combine),生成的路徑都是正確的,正斜槓** 2 **這也會產生相同的問題。 – ibnetariq
什麼是Unity版本,您正在測試的iOS版本是什麼? – Programmer
Unity = 5.4.1f1,Xcode = 7.3.1,Simulator = iPhone 5S和iOS = 9.3。同樣的問題也發生在設備上。我正在使用模擬器,所以我可以從Finder查看文檔目錄 – ibnetariq