Class DebugManager
The DebugManager class provides a centralized manager for handling Unity's Rendering debugger.
Inherited Members
Namespace: UnityEngine.Rendering
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
public sealed class DebugManager
Remarks
The DebugManager allows you to register, unregister, and manipulate debug data, panels, and widgets for runtime or editor debugging.
- Register and manage debug panels and widgets.
- Refresh and reset the debug UI based on runtime changes.
- Provides a global instance for easy access from anywhere in the codebase.
Examples
{
/// Create a list to store the new DebugUI widgets
/// by creating different DebugUI.Values that display a label with a value.
var list = new System.Collections.Generic.List<DebugUI.Widget>
{
new DebugUI.Value { displayName = "Lighting Intensity", getter = () => 1.0f, setter = value => Debug.Log($"Lighting Intensity set to {value}") },
new DebugUI.Value { displayName = "Light Color", getter = () => Color.white, setter = value => Debug.Log($"Light Color set to {value}") }
};
var items = list.ToArray();
/// Obtain the panel from the DebugManager instance, and add the Widgets that we want to display there.
var panel = DebugManager.instance.GetPanel("Lighting", true);
panel.children.AddRange(items);
}
Fields
refreshEditorRequested
Force an editor request.
Declaration
public bool refreshEditorRequested
Field Value
| Type | Description |
|---|---|
| bool |
Properties
displayEditorUI
Is the debug editor window open.
Declaration
public bool displayEditorUI { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
displayPersistentRuntimeUI
Displays the persistent runtime debug window.
Declaration
public bool displayPersistentRuntimeUI { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
displayRuntimeUI
Displays the runtime version of the debug window.
Declaration
public bool displayRuntimeUI { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
enableRuntimeUI
Controls whether runtime UI can be enabled. When this is set to false, there will be no overhead from debug GameObjects or runtime initialization.
Declaration
public bool enableRuntimeUI { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
instance
Global instance of the DebugManager.
Declaration
public static DebugManager instance { get; }
Property Value
| Type | Description |
|---|---|
| DebugManager |
isAnyDebugUIActive
Is any debug window or UI currently active.
Declaration
public bool isAnyDebugUIActive { get; }
Property Value
| Type | Description |
|---|---|
| bool |
panels
List of currently registered debug panels.
Declaration
public ReadOnlyCollection<DebugUI.Panel> panels { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlyCollection<DebugUI.Panel> |
Methods
FindPanelIndex(string)
Find the index of the panel from it's display name.
Declaration
public int FindPanelIndex(string displayName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | displayName | The display name of the panel to find. |
Returns
| Type | Description |
|---|---|
| int | The index of the panel in the list. -1 if not found. |
GetItem(string)
Get a Debug Item.
Declaration
public DebugUI.Widget GetItem(string queryPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | queryPath | Path of the debug item. |
Returns
| Type | Description |
|---|---|
| DebugUI.Widget | Reference to the requested debug item. |
GetItems(Flags)
Gets an DebugUI.Widget matching the given DebugUI.Flags
Declaration
public DebugUI.Widget[] GetItems(DebugUI.Flags flags)
Parameters
| Type | Name | Description |
|---|---|---|
| DebugUI.Flags | flags | The flags of the widget |
Returns
| Type | Description |
|---|---|
| Widget[] | Reference to the requested debug item. |
GetPanel(string, bool, int, bool)
Returns a debug panel.
Declaration
public DebugUI.Panel GetPanel(string displayName, bool createIfNull = false, int groupIndex = 0, bool overrideIfExist = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | displayName | Name of the debug panel. |
| bool | createIfNull | Create the panel if it does not exists. |
| int | groupIndex | Group index. |
| bool | overrideIfExist | Replace an existing panel. |
Returns
| Type | Description |
|---|---|
| DebugUI.Panel | The requested debug panel or null if it does not exist and createIfNull is set to false |
GetState()
Get hashcode state of the Debug Window.
Declaration
[Obsolete("This method is unused. #from(6000.5)")]
public int GetState()
Returns
| Type | Description |
|---|---|
| int | The calculated hashcode for the current state of the Debug Window. |
PanelDiplayName(int)
Returns the panel display name
Declaration
[Obsolete("Method is obsolete. Use PanelDisplayName instead. #from(6000.4) (UnityUpgradable) -> PanelDisplayName", true)]
public string PanelDiplayName(int panelIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | panelIndex | The panelIndex for the panel to get the name |
Returns
| Type | Description |
|---|---|
| string | The display name of the panel, or empty string otherwise |
PanelDisplayName(int)
Returns the panel display name
Declaration
public string PanelDisplayName(int panelIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | panelIndex | The panelIndex for the panel to get the name |
Returns
| Type | Description |
|---|---|
| string | The display name of the panel, or empty string otherwise |
PanelIndex(string)
Returns the panel index
Declaration
public int PanelIndex(string displayName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | displayName | The displayname for the panel |
Returns
| Type | Description |
|---|---|
| int | The index for the panel or -1 if not found. |
ReDrawOnScreenDebug()
Request the runtime debug UI be redrawn on the next update.
Declaration
[Obsolete("This method is obsolete. #from(6000.5)")]
public void ReDrawOnScreenDebug()
RefreshEditor()
Refresh the debug window.
Declaration
public void RefreshEditor()
RegisterData(IDebugData)
Register debug data.
Declaration
public void RegisterData(IDebugData data)
Parameters
| Type | Name | Description |
|---|---|---|
| IDebugData | data | Data to be registered. |
RemovePanel(string)
Remove a debug panel.
Declaration
public void RemovePanel(string displayName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | displayName | Name of the debug panel to remove. |
RemovePanel(Panel)
Remove a debug panel.
Declaration
public void RemovePanel(DebugUI.Panel panel)
Parameters
| Type | Name | Description |
|---|---|---|
| DebugUI.Panel | panel | Reference to the debug panel to remove. |
RequestEditorWindowPanel(string)
Request DebugWindow to open the specified panel.
Declaration
public void RequestEditorWindowPanel(string panelName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | panelName | Name of window panel to activate. |
RequestEditorWindowPanelIndex(int)
Request DebugWindow to open the specified panel.
Declaration
[Obsolete("Use RequestEditorWindowPanelName instead. #from(6000.5)")]
public void RequestEditorWindowPanelIndex(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Index of the debug window panel to activate. |
Reset()
Reset the debug window.
Declaration
public void Reset()
ToggleEditorUI(bool)
Toggle the debug window.
Declaration
[Obsolete("Use DebugManager.instance.displayEditorUI property instead. #from(2023.1)")]
public void ToggleEditorUI(bool open)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | open | State of the debug window. |
UnregisterData(IDebugData)
Register debug data.
Declaration
public void UnregisterData(IDebugData data)
Parameters
| Type | Name | Description |
|---|---|---|
| IDebugData | data | Data to be registered. |
Events
onDisplayRuntimeUIChanged
Callback called when the runtime UI changed.
Declaration
public event Action<bool> onDisplayRuntimeUIChanged
Event Type
| Type | Description |
|---|---|
| Action<bool> |
onSetDirty
Callback called when the debug window is dirty.
Declaration
public event Action onSetDirty
Event Type
| Type | Description |
|---|---|
| Action |
windowStateChanged
Event that is raised when a window state is changed
Declaration
public static event Action<DebugManager.UIMode, bool> windowStateChanged
Event Type
| Type | Description |
|---|---|
| Action<DebugManager.UIMode, bool> |