Game Development Reference
In-Depth Information
04 using System.IO;
05 //------------------------------------------------
06 public class ExceptionLogger : MonoBehaviour
07 {
08 //Internal reference to stream writer object
09 private System.IO.StreamWriter SW;
10
11 //Filename to assign log
12 public string LogFileName = "log.txt";
13
14 //------------------------------------------------
15 // Use this for initialization
16 void Start ()
17 {
18 //Make persistent
19 DontDestroyOnLoad(gameObject);
20
21 //Create string writer object
22 SW = new
System.IO.StreamWriter(Application.persistentDataPath + "/" +
LogFileName);
23
24 Debug.Log(Application.persistentDataPath + "/" +
LogFileName);
25 }
26 //------------------------------------------------
27 //Register for exception listening, and log exceptions
28 void OnEnable()
29 {
30 Application.RegisterLogCallback(HandleLog);
31 }
32 //------------------------------------------------
33 //Unregister for exception listening
34 void OnDisable()
35 {
36 Application.RegisterLogCallback(null);
37 }
 
Search WWH ::




Custom Search