1.4.1
Documentation for the Unity C# Library
Loading...
Searching...
No Matches
LogDisplayer.cs
Go to the documentation of this file.
1
using
UnityEngine;
2
using
System.Collections;
3
4
public
class
LogDisplayer
:
MonoBehaviour
5
{
6
string
currentLog
;
7
Queue
logQueue
=
new
Queue();
8
float
counter
= 0f;
9
10
void
Start
()
11
{
12
}
13
14
private
void
Update
()
15
{
16
if
(
logQueue
.Count > 0)
17
{
18
counter
+= Time.deltaTime;
19
20
if
(
counter
> 5.0f)
21
{
22
counter
-= 5.0f;
23
logQueue
.Dequeue();
24
RebuildLog
();
25
}
26
}
27
}
28
29
void
OnEnable
()
30
{
31
Application.logMessageReceived +=
HandleLog
;
32
}
33
34
void
OnDisable
()
35
{
36
Application.logMessageReceived -=
HandleLog
;
37
}
38
39
void
HandleLog
(
string
logString,
string
stackTrace, LogType type)
40
{
41
currentLog
= logString;
42
string
newString =
"\n ["
+ type +
"] : "
+
currentLog
;
43
44
logQueue
.Enqueue(newString);
45
46
if
(type == LogType.Exception)
47
{
48
newString =
"\n"
+ stackTrace;
49
logQueue
.Enqueue(newString);
50
}
51
52
RebuildLog
();
53
}
54
55
void
RebuildLog
()
56
{
57
currentLog
=
string
.Empty;
58
59
foreach
(
string
log
in
logQueue
)
60
{
61
currentLog
+= log;
62
}
63
}
64
65
void
OnGUI
()
66
{
67
GUIStyle labelStyle =
new
GUIStyle(GUI.skin.label);
68
labelStyle.normal.textColor = Color.red;
69
GUILayout.Label(
currentLog
, labelStyle);
70
}
71
}
LogDisplayer
Definition
LogDisplayer.cs:5
LogDisplayer.logQueue
Queue logQueue
Definition
LogDisplayer.cs:7
LogDisplayer.counter
float counter
Definition
LogDisplayer.cs:8
LogDisplayer.currentLog
string currentLog
Definition
LogDisplayer.cs:6
LogDisplayer.Update
void Update()
Definition
LogDisplayer.cs:14
LogDisplayer.RebuildLog
void RebuildLog()
Definition
LogDisplayer.cs:55
LogDisplayer.Start
void Start()
Definition
LogDisplayer.cs:10
LogDisplayer.HandleLog
void HandleLog(string logString, string stackTrace, LogType type)
Definition
LogDisplayer.cs:39
LogDisplayer.OnGUI
void OnGUI()
Definition
LogDisplayer.cs:65
LogDisplayer.OnEnable
void OnEnable()
Definition
LogDisplayer.cs:29
LogDisplayer.OnDisable
void OnDisable()
Definition
LogDisplayer.cs:34
MonoBehaviour
Samples
DemoApexReporter
DemoScene
LogDisplayer.cs
Generated
Mon Sep 16 2024 19:27:34
by Doxygen version
1.10.0