Quantcast
Channel: Questions in topic: "build"
Viewing all articles
Browse latest Browse all 4084

How to write to a file from a built Unity Game

$
0
0
Hello, I am trying to log game data from my unity game so I can analyze it later. The following code functions (it creates and writes to the intended file) when running the game in the editor, however when I build the game, my logging file fails to be created. This is how i save my logged information. public void SaveCSV() { string[][] output = new string[rows.Count][]; // my data is held in rows (List) //Convert rows into string [][] for (int i = 0; i < output.Length; i++) { output[i] = rows[i]; } int len = output.GetLength(0); string divider = ","; StringBuilder sb = new StringBuilder(); //convert output into csv format for (int index = 0; index < len; index++) sb.AppendLine(string.Join(divider, output[index])); string filePath = getPath(); //Returns Application.persistentDataPath + "/gameData.csv" //Save Data StreamWriter outStream = File.CreateText(filePath); outStream.WriteLine(sb); outStream.Close(); } Do I have to do something differently to get this function to save the .csv file from a built unity game? Any help would be appreciated. Thanks

Viewing all articles
Browse latest Browse all 4084

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>