问题描述
我开发了一款 Unity 游戏,将用于研究目的。玩家每关所需的时间写在一个txt文件中。在 PC 上它工作正常。但是当我在我的 PC 上使用 sidequest 或 android 文件传输阅读 Oculus 文件时,我在任何地方都找不到它。我将 Unity 中 Project Settings -> Write Permission
下的权限更改为 External(SD)
并在 Android Manifest.xml 中添加了以下几行:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
我还尝试了所有可能的路径(Application.dataPath
、Application.persistentDataPath
和 /sdcard/filename
、/mnt/sdcard/filename
、...)
我也重启过 Oculus 几次。
这是我正在创建和保存 txt 的代码:
if (SceneManager.GetActiveScene().name == "Level1")
{
//Path of the file
string path = Application.dataPath + "/SteamingAssets/CoordinateTimeLog" + ".txt";
//Create file if it doesn't exist
if(!File.Exists(path)){
File.WriteallText(path,"Path the Player walked (x,y,z) + Time in seconds\n\n");
}
//Content of the file
string content = "Level 1: " + transform.position +" "+ System.DateTime.Now + "\n\n";
//Add coordinates to it
File.AppendAllText(path,content);
}
在 AndroidManifest.xml 中,我在 </application>
下添加了以下内容:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
有人可以帮我吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)