I'm building an Oculus Go app with Unity but I can't figure out how to save a txt file to the Oculus Storage. I have read everything I've found online about it, including using solutions proposed on this website here and here.
I'm trying to create a text file that records which button from a toggle group was selected by the user.
When I build the same thing for PC the code works but I can't find the files inside the Oculus Go. I have edited the OVR android manifest and have a very simple script made from following a couple of tutorials.
Any help would be appreciated, thank you!
using UnityEngine;
using UnityEngine.UI;
using System.Linq;
using System.IO;
public class SubmitandWriteButtonOVR : MonoBehaviour
{
//GameObject
public ToggleGroup toggleGroup;
public void onClick()
{
string selectedLabel = toggleGroup.ActiveToggles()
.First().GetComponentsInChildren<Text>()
.First(t => t.name == "Label").text;
//Path of the file
string path = Application.persistentDataPath + "/Answers.txt";
//Create file if it doesn't exist
if (!File.Exists(path))
{
File.WriteAllText(path, "Answers");
}
//Content of the file Get the label in activated toggles
string content = "Selected Answers: \n" + System.DateTime.Now + "\n" + selectedLabel;
//Add some text
File.AppendAllText(path, content);
}
}