-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDebug.cs
More file actions
147 lines (124 loc) · 4.69 KB
/
Debug.cs
File metadata and controls
147 lines (124 loc) · 4.69 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
using System;
using System.Diagnostics;
using System.Threading;
using UnityEngine;
namespace ZeroPass
{
public static class Debug
{
public static bool isDebugBuild => UnityEngine.Debug.isDebugBuild;
public static bool developerConsoleVisible
{
get
{
return UnityEngine.Debug.developerConsoleVisible;
}
set
{
UnityEngine.Debug.developerConsoleVisible = value;
}
}
private static string TimeStamp()
{
return DateTime.UtcNow.ToString("[HH:mm:ss.fff] [") + Thread.CurrentThread.ManagedThreadId + "] ";
}
private static void WriteTimeStamped(params object[] objs)
{
string value = TimeStamp() + DebugUtil.BuildString(objs);
Console.WriteLine(value);
}
public static void Break()
{
}
public static void LogException(Exception exception)
{
UnityEngine.Debug.LogException(exception);
}
public static void Log(object obj)
{
WriteTimeStamped("[INFO]", obj);
}
public static void Log(object obj, UnityEngine.Object context)
{
WriteTimeStamped("[INFO]", (!(context != (UnityEngine.Object)null)) ? "null" : context.name, obj);
}
public static void LogFormat(string format, params object[] args)
{
WriteTimeStamped("[INFO]", string.Format(format, args));
}
public static void LogFormat(UnityEngine.Object context, string format, params object[] args)
{
WriteTimeStamped("[INFO]", (!(context != (UnityEngine.Object)null)) ? "null" : context.name, string.Format(format, args));
}
public static void LogWarning(object obj)
{
WriteTimeStamped("[WARNING]", obj);
}
public static void LogWarning(object obj, UnityEngine.Object context)
{
WriteTimeStamped("[WARNING]", (!(context != (UnityEngine.Object)null)) ? "null" : context.name, obj);
}
public static void LogWarningFormat(string format, params object[] args)
{
WriteTimeStamped("[WARNING]", string.Format(format, args));
}
public static void LogWarningFormat(UnityEngine.Object context, string format, params object[] args)
{
WriteTimeStamped("[WARNING]", (!(context != (UnityEngine.Object)null)) ? "null" : context.name, string.Format(format, args));
}
public static void LogError(object obj)
{
WriteTimeStamped("[ERROR]", obj);
UnityEngine.Debug.LogError(obj);
}
public static void LogError(object obj, UnityEngine.Object context)
{
WriteTimeStamped("[ERROR]", (!(context != (UnityEngine.Object)null)) ? "null" : context.name, obj);
UnityEngine.Debug.LogError(obj, context);
}
public static void LogErrorFormat(string format, params object[] args)
{
WriteTimeStamped("[ERROR]", string.Format(format, args));
UnityEngine.Debug.LogErrorFormat(format, args);
}
public static void LogErrorFormat(UnityEngine.Object context, string format, params object[] args)
{
WriteTimeStamped("[ERROR]", (!(context != (UnityEngine.Object)null)) ? "null" : context.name, string.Format(format, args));
UnityEngine.Debug.LogErrorFormat(context, format, args);
}
public static void Assert(bool condition)
{
if (!condition)
{
LogError("Assert failed");
Break();
}
}
public static void Assert(bool condition, object message)
{
if (!condition)
{
LogError("Assert failed: " + message);
Break();
}
}
public static void Assert(bool condition, object message, UnityEngine.Object context)
{
if (!condition)
{
LogError("Assert failed: " + message, context);
Break();
}
}
[Conditional("UNITY_EDITOR")]
public static void DrawLine(Vector3 start, Vector3 end, Color color = default(Color), float duration = 0f, bool depthTest = true)
{
UnityEngine.Debug.DrawLine(start, end, color, duration, depthTest);
}
[Conditional("UNITY_EDITOR")]
public static void DrawRay(Vector3 start, Vector3 dir, Color color = default(Color), float duration = 0f, bool depthTest = true)
{
UnityEngine.Debug.DrawRay(start, dir, color, duration, depthTest);
}
}
}