-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDebugConsole.cs
74 lines (53 loc) · 2.58 KB
/
DebugConsole.cs
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Firebase;
using Firebase.Database;
public class DebugConsole : MonoBehaviour {
//----------------------------------------------------------------------------------------------------------------------------------------------//
[SerializeField]
private UserAuthentication auth;
[SerializeField]
private RectTransform content;
[SerializeField]
private GameObject reportPrefab;
public Color green;
public Color orange;
public Color red;
private bool state = false;
//----------------------------------------------------------------------------------------------------------------------------------------------//
private void Update () {
if (Input.GetKeyDown (KeyCode.RightAlt)) {
ToggleDebug ();
}
}
//----------------------------------------------------------------------------------------------------------------------------------------------//
public void UpdateReport (string label, string message, Color status) {
if (content.Find (label) != null) {
content.Find (label).GetChild (0).GetComponent<Text> ().text = message;
content.Find (label).GetChild (1).GetComponent<Image> ().color = status;
} else {
AddNew (label, message, status);
}
}
//----------------------------------------------------------------------------------------------------------------------------------------------//
private void AddNew (string label, string message, Color status) {
GameObject newReport = Instantiate (reportPrefab, Vector3.zero, Quaternion.identity) as GameObject;
newReport.transform.SetParent (content);
newReport.name = label;
newReport.transform.localScale = new Vector3 (1.0f, 1.0f, 1.0f);
newReport.transform.GetChild (0).GetComponent<Text> ().text = message;
newReport.transform.GetChild (1).GetComponent<Image> ().color = status;
}
//----------------------------------------------------------------------------------------------------------------------------------------------//
public void ToggleDebug () {
state = !state;
if (state == true) {
transform.localScale = new Vector3 (1.0f, 1.0f, 1.0f);
} else {
transform.localScale = new Vector3 (0.0f, 0.0f, 0.0f);
}
}
//----------------------------------------------------------------------------------------------------------------------------------------------//
}