Hello,
I need to save my camera position and rotation to csv recurrently (minimum rate would be about 10 times per second). I have come across solutions such as c# - Saving streamed Data from Unity in a csv File - Stack Overflow (pasted below)
But this slows down my app and the number of saves varies between about 8 to 15 times per second on my machine. Is there a more efficient way to iteratively save to csv ?
Best wishes,
Eric
void update()
{
string filePath = @"C:\Data.csv";
string delimiter = ",";
Vector3 leftGazeDirection = smiInstance.smi_GetLeftGazeDirection();
Vector3 rightGazeDirection = smiInstance.smi_GetRightGazeDirection();
float[][] output = new float[][]{
new float[]{leftGazeDirection.x},
new float[]{leftGazeDirection.y},
new float[]{leftGazeDirection.z},
new float[]{rightGazeDirection.x},
new float[]{rightGazeDirection.y},
new float[]{rightGazeDirection.z} };
int length = output.GetLength(0);
StringBuilder sb = new StringBuilder();
for (int index = 0; index < length; index++)
sb.AppendLine(string.Join(delimiter, output[index]));
File.WriteAllText(@"C:\Data.csv", sb.ToString());
}