Hello community,
For a small study I designed an Unity apps that each experimentee has to play through. For easy access I want the game to be available online (no installation required) and thus I chose the WebGL build. While playing the game some game data is logged and should be saved in a text file at the end.
Currently my app is hosted only in my local network on a laptop and accessing the WebGL game works fine, but saving the data does not, or at least I can’t seem to find the files anywhere. The development build in unity runs without a single issue.
The game stats are simply saved in a file with the common SystemIO methods:
void SaveGameStats() {
string languageFolder = isSubjectEnglish ? "English" : "German";
string validityFolder = isValidSubject ? "Valid" : "Invalid";
string savePath = Path.Combine(Application.dataPath , "Game Stats", languageFolder, validityFolder);
if(!Directory.Exists(savePath)) {
Directory.CreateDirectory(savePath);
}
DateTime localDate = DateTime.Now;
var cultureGerman = new CultureInfo("de-DE");
string saveFileName = localDate.ToString(cultureGerman);
saveFileName = saveFileName.Replace(".", "_");
saveFileName = saveFileName.Replace(":", "_"); //Save file name in the format DD_MM_YY HH_MM_SS.txt
saveFileName += ".txt";
Debug.Log("File saved:" + Path.Combine(savePath, saveFileName));
using StreamWriter gameStatsFile = new StreamWriter(Path.Combine(savePath, saveFileName));
{
gameStatsFile.Write(dataAmountCorrectLevels.ToString() + "\n\n");
gameStatsFile.Write(dataChoiceTrueOrFalse + "\n");
gameStatsFile.Write(dataChosenOption + "\n");
gameStatsFile.Write(dataUsedTime + "\n");
}
}
My question regarding WebGL now:
-
In which directory are files stored under WebGL stored?
-
Are the saved locally in the browser, on the clients side file system or on the server side file system on which the WebGL game is setup?
-
In case they are stored not on the server side, what would be the best approach to transfer the file to the server/hosting laptop.
Thanks in advance. In case you need more information, feel free to ask me.