Unity How to write to text/log file

Create a class with a static function you can call whenever you want to write to a file.

FileUtil.cs
public static void log(string txt) {
	string now = System.DateTime.Now.ToString("dd-MM-yyyy HH:mm");
 
	// appends to file in game working dir
	System.IO.File.AppendAllText("log.txt", System.String.Format("[LOG {0}] {1}\r\n", now, txt));
}
Navigation
Print/export
Toolbox