EchoTrio
 
Loading...
Searching...
No Matches
ConversationLogger.cs
Go to the documentation of this file.
1using UnityEngine;
2using TMPro;
3using System.IO;
4
5namespace EchoTrio.Log {
6 public class ConversationLogger : MonoBehaviour {
7 [Header("References")]
8 public TextMeshProUGUI conversationText;
9
12 }
13
15 string timestamp = System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
16 string fileName = $"Playtest_{timestamp}.txt";
17
18 //create folder if not exists
19 string folderPath = Path.Combine(Application.dataPath, "PlaytestLogs");
20 Directory.CreateDirectory(folderPath);
21
22 string filePath = Path.Combine(folderPath, fileName);
23
24 using (StreamWriter writer = new StreamWriter(filePath, false)) {
25 writer.WriteLine("========== Playtest Session ==========");
26 writer.WriteLine("Timestamp: " + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
27 writer.WriteLine("Conversation History:");
28 writer.WriteLine(conversationText.text);
29 writer.WriteLine("======================================");
30 }
31
32 Debug.Log("Conversation saved to: " + filePath);
33 }
34 }
35}