Forum Discussion
white_lee
2 years agoHonored Guest
Question about data saving
Hello, how to save the game data in progress (ex. virtual helmet rotation y-axis) in the Oculus Quest2 helmet, and be able to open the folder to find the stored file data after the end.
I use this C# but not woking, how to test that data can save in helmet :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEngine.UI;
// private List<string[]> dataList = new List<string[]>(); //
// private string[] header = { "Name", "Age", "Gender" }; //
// private string filePath; // save path
public class DataRecorder : MonoBehaviour
{
private float[] yRotations;
private int currentIndex = 0;
public DataRecorder dataRecorder;
private void Awake()
{
yRotations = new float[1000]; //
}
public void RecordData(float yRotation)
{
yRotations[currentIndex++] = yRotation;
}
public string SaveDataToFile()
{
string filePath = Path.Combine(Application.persistentDataPath, "data.csv");
using (StreamWriter writer = new StreamWriter(filePath))
{
for (int i = 0; i < currentIndex; i++)
{
writer.WriteLine(yRotations[i]);
}
}
return filePath;
}
public void OnButtonClick()
{
float yRotation = transform.rotation.eulerAngles.y;
dataRecorder.RecordData(yRotation);
}
}
/* public float loggingInterval = 1f; // record time(sec)
public string logFileName = "head_rotation_log.txt"; //
private float timer = 0f;
private float lastYRotation = 0f;
private float currentYRotation = 0f;
private string logFilePath;
TimerController IOtime;*/
/*void Start()
{
logFilePath = Path.Combine(Application.dataPath, logFileName);
IOtime.timeElapsed = timer;
}*/
/* void Update()
{
currentYRotation = transform.rotation.eulerAngles.y; //
timer += Time.deltaTime;
if (timer >= loggingInterval)
{
float yRotationDelta = currentYRotation - lastYRotation;
Debug.Log("Y Rotation: " + yRotationDelta + " degrees in " + loggingInterval + " seconds");
using (StreamWriter writer = new StreamWriter(logFilePath, true))
{
writer.WriteLine("Y Rotation: " + yRotationDelta + " degrees in " + loggingInterval + " seconds");
}
lastYRotation = currentYRotation;
timer = 0f;
}
}*/
Replies have been turned off for this discussion
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 8 months ago
- 6 months ago
- 3 years ago