Skip to content

Commit 8ac13e1

Browse files
committed
Add UpdateDisplay to DebugManager
1 parent 5d80d0e commit 8ac13e1

File tree

6 files changed

+59
-16
lines changed

6 files changed

+59
-16
lines changed

Assets/_Project/Scripts/Core/DebugManager.cs

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,42 @@
11
using UnityEngine;
22
using System.Collections;
33
using System.Collections.Generic;
4+
using UnityEngine.UI;
5+
using TMPro;
6+
47

58
public class DebugManager : Singleton<DebugManager> {
69
// singleton
710
protected DebugManager () { }
8-
public static new DebugManager Instance;
11+
//public static new DebugManager Instance;
12+
13+
14+
15+
16+
// DISPLAY EVENT LOG
17+
18+
[Space (10)]
19+
[Header ("DEBUG LOG")]
20+
21+
public TMP_Text debugText;
22+
public ScrollRect debugScrollRect;
23+
24+
25+
926

1027
[SerializeField]
1128
public static bool status = true;
1229

1330
// dictionary of symbols
1431
private static Dictionary<string, string> symbolDictionary;
1532

33+
34+
1635
private void Awake ()
1736
{
18-
1937
AddSymbols ();
20-
38+
// clear display
39+
ClearDisplay ();
2140

2241
// turn off logging outside of the editor
2342
#if UNITY_EDITOR
@@ -29,6 +48,26 @@ private void Awake ()
2948

3049
}
3150

51+
52+
public void UpdateDisplay (string str)
53+
{
54+
//Debug.Log (str);
55+
if (str != "") str = str + "<br>";
56+
debugText.text += str;
57+
UpdateScroll ();
58+
}
59+
public void ClearDisplay ()
60+
{
61+
debugText.text = "";
62+
UpdateScroll ();
63+
}
64+
void UpdateScroll ()
65+
{
66+
Canvas.ForceUpdateCanvases ();
67+
debugScrollRect.verticalNormalizedPosition = 0f;
68+
}
69+
70+
3271
/**
3372
* Add symbols for debugging
3473
*/

Assets/_Project/Scripts/Core/EventManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ public static void StopListening (string eventName, UnityAction listener)
7373

7474
public static void TriggerEvent (string eventName)
7575
{
76-
7776
// if application is playing
7877
if (Application.IsPlaying (instance)) {
79-
Debug.Log (DebugManager.GetSymbol ("blackstar") + " EventManager.TriggerEvent() -> eventName = " + eventName);
78+
//Debug.Log (DebugManager.GetSymbol ("blackstar") + " EventManager.TriggerEvent() -> eventName = " + eventName);
79+
DebugManager.Instance.UpdateDisplay ("EventManager.TriggerEvent() eventName = " + eventName);
8080
}
8181

8282
UnityEvent thisEvent = null;

Assets/_Project/Scripts/Core/ResolutionManager.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ private void Update ()
110110

111111
IEnumerator SendResolutionUpdatedEvent ()
112112
{
113-
Debug.Log ("ResolutionManager.SendResolutionUpdatedEvent() - resolution has changed to " + playerResolution.ToString ());
114-
113+
//Debug.Log ("ResolutionManager.SendResolutionUpdatedEvent() - resolution has changed to " + playerResolution.ToString ());
114+
// if application is playing
115+
if (Application.IsPlaying (gameObject)) {
116+
DebugManager.Instance.UpdateDisplay ("ResolutionManager.SendResolutionUpdatedEvent() - resolution has changed to " + playerResolution.ToString ());
117+
}
115118
// update the parameters
116119
UpdateResolutionParams ();
117120

Assets/_Project/Scripts/Data/DataManager.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void GetNewData ()
9898
// update path
9999
path = hosts [(int)chosenHost] + endpoints [(int)chosenEndpoint];
100100

101-
//Debug.Log (DebugManager.GetSymbol ("asterisk") + " DataManager.GetNewData() path = " + path);
101+
DebugManager.Instance.UpdateDisplay (DebugManager.GetSymbol ("asterisk") + " DataManager.GetNewData() path = " + path);
102102

103103
StartCoroutine (GetRequest (path));
104104

@@ -120,9 +120,8 @@ public static IEnumerator GetRequest (string uri)
120120
if (webRequest.isNetworkError || webRequest.isHttpError) {
121121
Debug.Log (DebugManager.GetSymbol ("asterisk") + " Error: " + webRequest.error);
122122
} else {
123-
Debug.Log (DebugManager.GetSymbol ("asterisk") + " DataManager.GetNewData() " +
124-
//uri + "\n" + webRequest.downloadHandler.text +
125-
"");
123+
//Debug.Log (DebugManager.GetSymbol ("asterisk") + " DataManager.GetNewData() " + uri + "\n" + webRequest.downloadHandler.text);
124+
DebugManager.Instance.UpdateDisplay ("DataManager.GetNewData() uri = " + uri);
126125

127126
// parse JSON array
128127
JArray a = JArray.Parse (webRequest.downloadHandler.text);

Assets/_Project/Scripts/Data/JsonData.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ void ParseGradientsByMid (string text)
6969
// parse the string as JObject
7070
JObject jsonData = JObject.Parse (text);
7171

72-
print ("---- GradientsByMidPoint -> count: " + jsonData.Count);
72+
//Debug.Log ("---- GradientsByMidPoint -> count: " + jsonData.Count);
73+
DebugManager.Instance.UpdateDisplay ("JsonData.ParseGradientsByMid() GradientsByMidPoint count = " + jsonData.Count);
7374

7475
// loop through each, accessing it as a string:JToken
7576
foreach (KeyValuePair<string, JToken> item in jsonData) {
@@ -89,7 +90,8 @@ void ParseMonstersByMid (string text)
8990
// parse the string as JObject
9091
JObject jsonData = JObject.Parse (text);
9192

92-
print ("---- MonstersByMidPoint -> count: " + jsonData.Count);
93+
//Debug.Log ("---- MonstersByMidPoint -> count: " + jsonData.Count);
94+
DebugManager.Instance.UpdateDisplay ("JsonData.ParseGradientsByMid() MonstersByMidPoint count = " + jsonData.Count);
9395

9496
// loop through each, accessing it as a string:JToken
9597
foreach (KeyValuePair<string, JToken> item in jsonData) {

Assets/_Project/Scripts/Data/TimelineManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public class TimelineManager : Singleton<TimelineManager> {
99
// singleton
1010
protected TimelineManager () { }
11-
//public static new PlayerManager Instance;
11+
//public static new TimelineManager Instance;
1212

1313

1414
// PLAYBACK
@@ -93,7 +93,7 @@ IEnumerator Play ()
9393
// log feed item
9494
var eventString =
9595

96-
feedIndex + ". " +
96+
9797
timeDiff + " (" + timeDiffScaled + ") " +
9898

9999
" (" + feed.createdAt + ") " +
@@ -118,7 +118,7 @@ IEnumerator Play ()
118118
UpdateScroll ();
119119

120120

121-
Debug.Log (eventString);
121+
DebugManager.Instance.UpdateDisplay ("Timeline.PlayEvent() " + eventString);
122122

123123

124124
// set previous time for next loop

0 commit comments

Comments
 (0)