Class ConnectorHud
An immediate-mode debug HUD MonoBehaviour that renders connector status headers, tabbed content panels, and draggable HudWindow overlays during play mode.
Inherited Members
Namespace: Unity.SimulationPro.Foundation
Assembly: Unity.SimulationPro.Foundation.dll
Syntax
public class ConnectorHud : MonoBehaviour
Remarks
The HUD is automatically instantiated at runtime when the first tab or header is registered via RegisterTab(IConnector, IHudTab, int) or RegisterHeader(IConnector, Action, int). The static registration methods can be called at any time regardless of initialization order. All static state is cleared when exiting play mode in the Editor.
Fields
s_BoldStyle
A bold white left-aligned GUIStyle for HUD header text.
Declaration
public static GUIStyle s_BoldStyle
Field Value
| Type | Description |
|---|---|
| GUIStyle |
s_ConnectionArrowStyle
A large bold white GUIStyle used for connection arrow symbols.
Declaration
public static GUIStyle s_ConnectionArrowStyle
Field Value
| Type | Description |
|---|---|
| GUIStyle |
s_ContentStyle
A plain white left-aligned GUIStyle for HUD content text.
Declaration
public static GUIStyle s_ContentStyle
Field Value
| Type | Description |
|---|---|
| GUIStyle |
Methods
AddWindow(HudWindow)
Adds a HudWindow to the list of active windows rendered each frame.
Declaration
public static void AddWindow(HudWindow window)
Parameters
| Type | Name | Description |
|---|---|---|
| HudWindow | window | The window to add. |
DrawConnectionArrows(bool, float, float, DateTime, DateTime, bool, bool, bool)
Draws send/receive arrow indicators at the specified screen position using immediate-mode GUI.
Declaration
public static void DrawConnectionArrows(bool withBar, float x, float y, DateTime receivedTime, DateTime sentTime, bool isPublisher, bool isSubscriber, bool hasError)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | withBar | Whether to draw a vertical separator bar before the arrows. |
| float | x | The screen X coordinate of the indicator. |
| float | y | The screen Y coordinate of the indicator. |
| DateTime | receivedTime | The wall-clock time at which the last message was received. |
| DateTime | sentTime | The wall-clock time at which the last message was sent. |
| bool | isPublisher | Whether this topic has an active publisher. |
| bool | isSubscriber | Whether this topic has an active subscriber. |
| bool | hasError | Whether the connection has an error state. |
GetConnectionColor(double, bool, bool)
Returns a color indicating connection activity based on elapsed time since the last message.
Declaration
public static Color GetConnectionColor(double elapsedTime, bool hasConnection, bool hasError)
Parameters
| Type | Name | Description |
|---|---|---|
| double | elapsedTime | Seconds elapsed since the last message was sent or received. |
| bool | hasConnection | Whether the connection (publisher or subscriber) is active. |
| bool | hasError | Whether the connection has an error state. |
Returns
| Type | Description |
|---|---|
| Color | A bright yellow color immediately after activity, fading to dark blue over time. Gray if no connection; red if there is an error. |
GetDefaultWindowRect()
Returns the default screen rectangle used for new HUD windows.
Declaration
public static Rect GetDefaultWindowRect()
Returns
| Type | Description |
|---|---|
| Rect | A Rect positioned at (450, 0) with size 300×200. |
GetFreeWindowRect()
Returns a screen rectangle that does not overlap any currently active HudWindow.
Declaration
public Rect GetFreeWindowRect()
Returns
| Type | Description |
|---|---|
| Rect | A free Rect suitable for placing a new window. |
GetNextWindowID()
Returns a unique window ID for use with GUI.Window.
Declaration
public static int GetNextWindowID()
Returns
| Type | Description |
|---|---|
| int | An integer ID that has not been returned by a previous call. |
Instantiate()
Ensures the singleton ConnectorHud GameObject exists in the scene. Creates it if it does not yet exist. Does nothing outside of play mode.
Declaration
public static void Instantiate()
IsFreeWindowRect(Rect)
Returns a value indicating whether the specified rectangle does not overlap any active window.
Declaration
public bool IsFreeWindowRect(Rect rect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | The rectangle to test. |
Returns
| Type | Description |
|---|---|
| bool |
|
IsFreeWindowRect(Rect, out float, out float)
Returns a value indicating whether the specified rectangle is free, and outputs the maximum extents of any overlapping windows to assist in finding the next free position.
Declaration
public bool IsFreeWindowRect(Rect rect, out float maxX, out float maxY)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | The rectangle to test. |
| float | maxX | The maximum X extent of all windows that overlap |
| float | maxY | The maximum Y extent of all windows that overlap |
Returns
| Type | Description |
|---|---|
| bool |
|
RegisterHeader(IConnector, Action, int)
Registers a GUI action to be drawn in the header area of the HUD panel for the specified connector.
Declaration
public static void RegisterHeader(IConnector connector, Action headerContent, int index = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| IConnector | connector | The connector whose panel this header belongs to. |
| Action | headerContent | The action that draws the header content using immediate-mode GUI. |
| int | index | The preferred ordering index within the header area. |
RegisterTab(IConnector, IHudTab, int)
Registers a tab to be displayed in the HUD panel for the specified connector.
Declaration
public static void RegisterTab(IConnector connector, IHudTab tab, int index = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| IConnector | connector | The connector whose panel this tab belongs to. |
| IHudTab | tab | The tab to register. |
| int | index | The preferred ordering index. If another tab occupies this index, the index is incremented until a free slot is found. Use HudTabOrdering values for built-in slots. |
RemoveWindow(HudWindow)
Removes a HudWindow from the active window list.
Declaration
public static void RemoveWindow(HudWindow window)
Parameters
| Type | Name | Description |
|---|---|---|
| HudWindow | window | The window to remove. |
Unregister(IConnector)
Removes all HUD tabs and headers registered for the specified connector.
Declaration
public static void Unregister(IConnector connector)
Parameters
| Type | Name | Description |
|---|---|---|
| IConnector | connector | The connector to unregister from the HUD. |
UnregisterTab(IConnector, IHudTab)
Removes a previously registered tab from the HUD panel for the specified connector.
Declaration
public static void UnregisterTab(IConnector connector, IHudTab tab)
Parameters
| Type | Name | Description |
|---|---|---|
| IConnector | connector | The connector whose panel the tab was registered with. |
| IHudTab | tab | The tab to remove. |