I’m working on an application that records some information and stores the data in a serialized JSON file with the following code:
string DatabasePath = $"{Application.streamingAssetsPath}/HardPoints/";
string FileName = "HardPointData.json";
if (!Directory.Exists(DatabasePath)) Directory.CreateDirectory(DatabasePath);
if (File.Exists($"{DatabasePath}{FileName}")) File.Create($"{DatabasePath}{FileName}");
File.WriteAllText($"{DatabasePath}{FileName}", JsonConvert.SerializeObject(JSONData));
AssetDatabase.Refresh();
Despite adding the AssetDatabase.Refresh after saving the file, the file results as empty. While the application is running in Play mode within the editor the file and the data inside exist but the moment I stop the editor all of the file’s data vanishes.
Can someone tell me what I’m doign wrong? Is there some exception for the streamingAssetsPath? What am I missing?