Game.Debug.WatchersDebugUI
Assembly: Game (inferred)
Namespace: Game.Debug
Type: class
Base: System.IDisposable
Summary:
A debug UI container that exposes the in-game "Watchers" debug tab. This class integrates with the debug UI system via attributes ([DebugContainer] and [DebugTab]) and constructs the widgets used to inspect and control the DebugWatchSystem (enabling it, refreshing its list, clearing watches, and showing per-system foldouts). The class is intended to be discovered/used by the game's debug UI infrastructure rather than being instantiated and driven directly by gameplay code.
Fields
private DebugWatchSystem m_WatchSystem
Holds a reference to the DebugWatchSystem instance for the provided World. The field is populated inside BuildWatchersDebugUI by calling World.GetOrCreateSystemManaged() so the UI can enable/disable the watch system and call its helper methods (ClearWatches, BuildSystemFoldouts, etc.).
Properties
- None (this class has no public properties)
Constructors
public WatchersDebugUI()
Implicit default constructor (none defined explicitly in source). The class is attributed with [DebugContainer] and is expected to be constructed/managed by the debug framework.
Methods
-
private void Rebuild()
Triggers a rebuild of the debug UI by calling DebugSystem.Rebuild(BuildWatchersDebugUI). This forces the debug system to re-evaluate widgets built by the provided builder method. Used as the action for the "Refresh System List" button. -
public void Dispose()
Implements IDisposable. Ensures the DebugWatchSystem.Enabled flag is set to true only when there are active watches; otherwise disables the watch system when no watches remain: -
m_WatchSystem.Enabled = m_WatchSystem.watches.Count > 0; This is used for cleanup when the debug container is disposed.
-
[DebugTab("Watchers", -975)] private List<DebugUI.Widget> BuildWatchersDebugUI(World world)
Builds and returns the list of widgets that make up the "Watchers" debug tab. Although declared private, the method is annotated with [DebugTab] so the debug framework discovers and invokes it. Implementation steps: - Obtains (or creates) the DebugWatchSystem for the provided World: world.GetOrCreateSystemManaged
(). - Enables the watch system (m_WatchSystem.Enabled = true).
- Creates a widget list and adds:
- A DebugUI.Button labeled "Refresh System List" that calls Rebuild().
- A DebugUI.Button labeled "Clear Watches" that calls m_WatchSystem.ClearWatches.
- The foldout widgets produced by m_WatchSystem.BuildSystemFoldouts().
- Returns the assembled list of DebugUI.Widget.
Notes: - The method depends on types provided by the game's debug framework: DebugSystem, DebugUI.Widget/DebugUI.Button, DebugWatchSystem, and the ECS World API (GetOrCreateSystemManaged). - The DebugTab attribute includes a sort order (-975) which controls tab ordering in the debug UI.
Usage Example
// The debug system discovers this container via the [DebugContainer] attribute
// and invokes the method annotated with [DebugTab]. You don't normally call
// BuildWatchersDebugUI directly, but you can conceptualize usage like this:
// (Pseudo-usage — the actual debug framework calls BuildWatchersDebugUI automatically)
var container = new Game.Debug.WatchersDebugUI();
// The debug framework will call the private BuildWatchersDebugUI(world) method and render widgets.
// When the container is disposed by the debug framework:
container.Dispose();
// Inside BuildWatchersDebugUI, the class does something like:
m_WatchSystem = world.GetOrCreateSystemManaged<DebugWatchSystem>();
m_WatchSystem.Enabled = true;
var list = new List<DebugUI.Widget>();
list.Add(new DebugUI.Button { displayName = "Refresh System List", action = Rebuild });
list.Add(new DebugUI.Button { displayName = "Clear Watches", action = m_WatchSystem.ClearWatches });
list.AddRange(m_WatchSystem.BuildSystemFoldouts());
return list;
Additional notes for modders: - Because BuildWatchersDebugUI is private and discovered via attributes, use the same attribute pattern to add new debug containers/tabs. Ensure your debug methods are compatible with the debug framework's discovery rules. - Be careful when manipulating m_WatchSystem.Enabled — enabling the watch system when not needed can incur runtime overhead. The Dispose method ensures the watch system is disabled when no watches remain.