-
Notifications
You must be signed in to change notification settings - Fork 869
Expand file tree
/
Copy pathDebugDisplaySettingsUI.cs
More file actions
110 lines (88 loc) · 3.78 KB
/
DebugDisplaySettingsUI.cs
File metadata and controls
110 lines (88 loc) · 3.78 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
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine.Rendering.RenderGraphModule;
namespace UnityEngine.Rendering
{
/// <summary>
/// The UI implementation for a debug settings panel
/// </summary>
public class DebugDisplaySettingsUI : IDebugData
{
private IEnumerable<IDebugDisplaySettingsPanelDisposable> m_DisposablePanels;
private IDebugDisplaySettings m_Settings;
private void Reset()
{
if (m_Settings != null)
{
m_Settings.Reset();
// TODO: Tear the UI down and re-create it for now - this is horrible, so reset it instead.
UnregisterDebug();
RegisterDebug(m_Settings);
DebugManager.instance.RefreshEditor();
}
}
/// <summary>
/// Register a display for the UI
/// </summary>
/// <param name="settings"><see cref="IDebugDisplaySettings"/> to be registered</param>
public void RegisterDebug(IDebugDisplaySettings settings)
{
DebugManager debugManager = DebugManager.instance;
List<IDebugDisplaySettingsPanelDisposable> panels = new List<IDebugDisplaySettingsPanelDisposable>();
debugManager.RegisterData(this);
m_Settings = settings;
m_DisposablePanels = panels;
m_Settings.Add(new DebugDisplaySettingsRenderGraph());
Action<IDebugDisplaySettingsData> onExecute = (data) =>
{
IDebugDisplaySettingsPanelDisposable disposableSettingsPanel = data.CreatePanel();
DebugUI.Widget[] panelWidgets = disposableSettingsPanel.Widgets;
DebugUI.Panel panel = debugManager.GetPanel(
displayName: disposableSettingsPanel.PanelName,
createIfNull: true,
groupIndex: (disposableSettingsPanel is DebugDisplaySettingsPanel debugDisplaySettingsPanel) ? debugDisplaySettingsPanel.Order : 0);
#if UNITY_EDITOR
if (DocumentationUtils.TryGetHelpURL(disposableSettingsPanel.GetType(), out var documentationUrl))
panel.documentationUrl = documentationUrl;
#endif
ObservableList<DebugUI.Widget> panelChildren = panel.children;
panel.flags = disposableSettingsPanel.Flags;
panels.Add(disposableSettingsPanel);
panelChildren.Add(panelWidgets);
};
m_Settings.ForEach(onExecute);
}
/// <summary>
/// Unregister the debug panels
/// </summary>
public void UnregisterDebug()
{
DebugManager debugManager = DebugManager.instance;
if (m_DisposablePanels != null)
{
foreach (IDebugDisplaySettingsPanelDisposable disposableSettingsPanel in m_DisposablePanels)
{
DebugUI.Widget[] panelWidgets = disposableSettingsPanel.Widgets;
string panelId = disposableSettingsPanel.PanelName;
DebugUI.Panel panel = debugManager.GetPanel(panelId, true);
ObservableList<DebugUI.Widget> panelChildren = panel.children;
disposableSettingsPanel.Dispose();
panelChildren.Remove(panelWidgets);
}
m_DisposablePanels = null;
}
debugManager.UnregisterData(this);
}
#region IDebugData
/// <summary>
/// The reset action to be executed when a Reset of the rendering debugger is need
/// </summary>
/// <returns>A <see cref="Action"/> with the restet callback</returns>
public Action GetReset()
{
return Reset;
}
#endregion
}
}