2

I have developed a Unity game that will be used for research purposes. The time that the player needs per level is written in a txt file. On PC it works fine. But I can't find it anywhere when I read the Oculus files with sidequest or android file transfer on my PC. I changed the permission in Unity under Project Settings -> Write Permission to External(SD) and added the lines in the Android Manifest.xml:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

I have also tried all possible paths (Application.dataPath, Application.persistentDataPath and /sdcard/filename, /mnt/sdcard/filename,...) I have also restarted the Oculus several times.

This is the code I'm creating and saving the 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);
        }

In the AndroidManifest.xml I've added the following under </application>:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
9Ilkp
  • 21
  • 3
  • Could you show your code? As alternative I'd recommend to directly send the data to the PC e.g. via TCP or (what I did for my thesis) host an HTTP server on the PC and directly wrote the file to the PC via web request – derHugo Jul 13 '21 at 20:46
  • I've added the code in the question. Thanks for the alternatives. I'll check them – 9Ilkp Jul 14 '21 at 21:04
  • Streaming assets is **read-only** after a build! Rather use the [persistentDataPath](https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html)! – derHugo Jul 14 '21 at 21:06
  • Also do you get any error or only `I can't find it anywhere`? – derHugo Jul 14 '21 at 21:09
  • I've also already tried the persistentDataPath. And no, I don't get any error. There is just nothing in visible in any folder when I search the folders via sidequest or android file transfer – 9Ilkp Jul 15 '21 at 07:54
  • Did you manage to resolve this issue? – HeyMate Jan 07 '22 at 04:43

0 Answers0