private void Awake() { if (PlayerPrefs.GetInt("Recording") == 1) { _isRecording = true; } UnityEngine.Debug.Log(_isRecording); _logDir = Path.Combine(Application.dataPath, "PlayerRecordings"); if (!Directory.Exists(_logDir)) { Directory.CreateDirectory(_logDir); } playerData = new PlayerData(); playerData.headDataList = new List <PlayerData.HeadData>(); playerData.evidenceList = new List <PlayerData.Evidence>(); playerData.observationList = new List <PlayerData.LookingBehaviour>(); playerData.timeStampList = new List <string>(); playerData.pNumber = PlayerPrefs.GetInt("Participant Number"); playerData.condition = PlayerPrefs.GetString("Condition"); _logFile = string.Format("log{0}-PNum{1}_Con_{2}.json", System.DateTime.Now.ToString("dd-MM-yyyy"), playerData.pNumber, playerData.condition); _logFilePath = Path.Combine(_logDir, _logFile); _stopwatch = new Stopwatch(); _head = new PlayerData.HeadData(); evidenceData = new PlayerData.Evidence(); lookingData = new PlayerData.LookingBehaviour(); UnityEngine.Debug.Log("Log files stored to: " + _logDir); }
private void OnApplicationQuit() { if (PlayerPrefs.GetString("Condition").Equals("HitAndRun")) { foreach (KeyValuePair <string, string> item in RayHitEvidence._evidenceTable) { lookingData = new PlayerData.LookingBehaviour(); lookingData.name = item.Key; lookingData.time = item.Value; playerData.observationList.Add(lookingData); } } if (_isRecording) { if (DataHandler.instance.isWatchRunning()) { DataHandler.instance.endRecordingEvidence(); } UnityEngine.Debug.Log("Exiting application and writing to file."); WriteToFile(); } }