aboutsummaryrefslogtreecommitdiff
path: root/td/Assets/Scripts/developerMode.cs
blob: b0d7704562c5c9155355cda7da817e8a71dc61dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;

public class developerMode : MonoBehaviour {

	public string output = "";
	public string stack = "";

	bool developerModeActive;
	GameObject pnlCanvas;
	Text lblConsoleLog;

	void Start () {
		pnlCanvas = transform.Find ("Canvas").gameObject;
		lblConsoleLog = pnlCanvas.transform.Find ("consoleLog").gameObject.GetComponent <Text>();

		lblConsoleLog.text = "";
	}

	void Update () {
		
		if (PlayerPrefs.HasKey ("developerMode")) {
			if (PlayerPrefs.GetInt ("developerMode") == 1) { developerModeActive = true; }
			else { developerModeActive = false; }
		}

		if (developerModeActive) {
			this.gameObject.transform.GetChild (0).gameObject.SetActive (true);
		} else {
			this.gameObject.transform.GetChild (0).gameObject.SetActive (false);
		}
	}
		

	void OnEnable() {
		Application.logMessageReceived += HandleLog;
	}
	void OnDisable() {
		Application.logMessageReceived -= HandleLog;
	}
	public void HandleLog(string logString, string stackTrace, LogType type) {
		string backLog = lblConsoleLog.text;
		lblConsoleLog.text = logString + "\n" + backLog;
	}

}