Game.Debug.UIBindingDebugUI
Assembly: Game
Namespace: Game.Debug
Type: static class
Base: System.Object
Summary:
Utility debug container that builds a debug UI tab ("UI Bindings") listing the game's UI data bindings. It enumerates bindings from GameManager.instance.userInterface.bindings and creates DebugUI widgets grouped by binding group names. The class is discovered/registered via the [DebugContainer] and [DebugTab("UI Bindings", -970)] attributes — you do not need to manually register it. It provides a "Refresh" button to rebuild the list and a "Clear" button to stop observing any binding. The UI supports trigger, event/value selection, and generic-type display for other binding types.
Fields
- (none)
This class has no instance or static fields.
Properties
- (none)
No properties are exposed by this debug helper.
Constructors
- (none)
This is a static utility class; it does not define constructors.
Methods
-
private static void Rebuild()
This invokes DebugSystem.Rebuild(BuildUIBindingsDebugUI), forcing the debug system to rebuild the "UI Bindings" tab content. It is used as the action for the "Refresh" button in the debug UI. -
private static void AddBindingButtonsRecursive(DebugUISystem debugUIsystem, Dictionary<string, DebugUI.Container> containers, IBindingGroup group)
Walks the supplied IBindingGroup (and nested groups) and converts each IBinding into appropriate DebugUI widgets: - If the binding implements IDebugBinding, it is grouped by IDebugBinding.group (creating a DebugUI.Foldout for each group).
- For DebugBindingType.Trigger bindings, adds a DebugUI.Button that calls debugUIsystem.Trigger(debugBinding).
- For DebugBindingType.Event or DebugBindingType.Value bindings, adds a DebugUI.BoolField to toggle observing that binding (sets debugUIsystem.observedBinding).
-
For other bindings, adds a DebugUI.Value showing the binding type (formatted generically). Recurses into nested IBindingGroup entries.
-
private static string FormatGenericTypeString(Type t)
Formats a Type into a readable name including generic type arguments. For non-generic types returns Type.Name. For generics it returns "TypeName" recursively formatting generic argument types. -
private static List<DebugUI.Widget> BuildUIBindingsDebugUI(World world)
[DebugTab("UI Bindings", -970)]
Entry method used by the debug UI system to construct the list of widgets for the "UI Bindings" debug tab. It: - Retrieves DebugUISystem from the provided World.
- Retrieves the binding registry from GameManager.instance.userInterface.bindings.
- Builds grouped containers of widgets via AddBindingButtonsRecursive.
- Prepends two buttons: "Refresh" (calls Rebuild) and "Clear" (clears debugUISystem.observedBinding).
- Returns the assembled list of DebugUI.Widget items (foldouts and controls), ordered by container displayName.
Usage Example
// The UIBindingDebugUI class is auto-discovered via attributes and will appear
// under the debug tab "UI Bindings". You normally don't call its private methods
// directly. Example showing how to programmatically trigger a debug binding:
var world = /* obtain World instance from context */;
var debugUISystem = world.GetOrCreateSystemManaged<DebugUISystem>();
var bindings = GameManager.instance.userInterface.bindings;
if (bindings != null)
{
foreach (IBinding binding in bindings.bindings)
{
if (binding is IDebugBinding debugBinding && debugBinding.name == "MyTrigger")
{
// Invoke the binding's trigger via the debug UI system, same as the UI button does.
debugUISystem.Trigger(debugBinding);
break;
}
}
}
// To clear observed binding programmatically (same as the "Clear" button):
debugUISystem.observedBinding = null;
Additional notes: - The debug tab shows bindings grouped by IDebugBinding.group. For Event/Value bindings the UI allows toggling "observed" state to inspect live values/events. Trigger bindings can be invoked from the UI. - If you add or modify bindings at runtime, press "Refresh" in the debug tab (or call DebugSystem.Rebuild via your own code) to update the displayed list.