-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebugPanel.cs
More file actions
82 lines (67 loc) · 2.54 KB
/
Copy pathdebugPanel.cs
File metadata and controls
82 lines (67 loc) · 2.54 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
/*
debugPanel.cs
Tony Monckton (c) 2019
*/
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace TM.Utils {
public class debugPanel : EditorWindow
{
private bool _expanded = false;
private GUIStyle guiStyle = new GUIStyle();
private GUIStyle guiStyleFoldout = new GUIStyle();
Dictionary<string, bool> catToggle = new Dictionary<string, bool>();
List<bool> catExpaned = new List<bool>();
[MenuItem("TM Utils/Debug Panel")]
public static void ShowWindow()
{
GetWindow<debugPanel>(false, "DebugPanel", true);
}
void OnGUI()
{
guiStyle.fontSize = 15;
guiStyle.margin = new RectOffset(15,5,2,2);
guiStyleFoldout.fontSize = 15;
guiStyleFoldout.fontStyle = FontStyle.Bold;
guiStyleFoldout = "Foldout";
// dropdown
EditorGUILayout.BeginVertical();
Dictionary<string, MessageLog>msgs = debugLog.instance.messageLog;
var ordered = msgs.OrderBy(x => x.Value.category);
string cat = "";
bool e = false;
foreach(KeyValuePair<string, MessageLog> entry in ordered)
{
if ( cat != entry.Value.category) {
cat = entry.Value.category;
if ( catToggle.ContainsKey(cat) == false) {
catToggle.Add(cat, true);
}
e = GUILayout.Toggle(catToggle[cat], cat, guiStyleFoldout, GUILayout.ExpandWidth(false));
catToggle[cat] = e;
}
if (e) {
string msg = entry.Value.name + ": " + entry.Value.text;
GUILayout.Label(msg, guiStyle);
}
}
EditorGUILayout.EndVertical();
GUILayout.FlexibleSpace();
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.backgroundColor = Color.grey;
GUI.color = Color.white;
// reset things...
if (GUILayout.Button("Reset", GUILayout.Width(100), GUILayout.Height(30)))
{
}
EditorGUILayout.EndHorizontal();
}
public void OnInspectorUpdate()
{
this.Repaint();
}
}
}