Class DebugCanvasUtil
Creates and configures a screen-space debug canvas and ensures an UnityEngine.EventSystems.EventSystem exists in the scene.
Inherited Members
Namespace: Scylla.Core.Util.UI
Assembly: ScyllaCore.dll
Syntax
public static class DebugCanvasUtil
Remarks
This class provides the minimal uGUI infrastructure required to render debug
overlays (such as an in-game console or performance monitor) without depending on
a dedicated UI module. The created canvas uses ScreenSpaceOverlay with a
very high sorting order so debug content draws above regular game UI.
The canvas is configured with CanvasScaler.ScaleMode.ConstantPixelSize
(scale factor 1) and a GraphicRaycaster to support pointer interactions
with debug UI elements.
When an UnityEngine.EventSystems.EventSystem is created automatically it prefers
InputSystemUIInputModule (Unity Input System) via reflection and falls
back to StandaloneInputModule to avoid a hard assembly dependency on
the Input System package.
Fields
DEFAULT_CANVAS_NAME
Default name assigned to the debug canvas GameObject when none is specified.
Declaration
public const string DEFAULT_CANVAS_NAME = "Scylla Debug Canvas"
Field Value
| Type | Description |
|---|---|
| string |
DEFAULT_SORTING_ORDER
Default canvas sorting order used when creating a debug canvas. Set to
short.MaxValue - 100 (32667) so debug overlays render above typical
game UI while still leaving room for higher-priority system overlays.
Declaration
public const int DEFAULT_SORTING_ORDER = 32667
Field Value
| Type | Description |
|---|---|
| int |
Methods
CreateDebugCanvas(int, string, bool)
Creates a new ScreenSpaceOverlay canvas configured for debug overlays
and calls EnsureEventSystem() so the canvas can receive pointer input.
Declaration
public static Canvas CreateDebugCanvas(int sortingOrder = 32667, string name = "Scylla Debug Canvas", bool persistAcrossScenes = true)
Parameters
| Type | Name | Description |
|---|---|---|
| int | sortingOrder | The canvas sorting order. Higher values draw on top of lower values. Defaults to DEFAULT_SORTING_ORDER. |
| string | name | The name to assign to the canvas GameObject. Defaults to DEFAULT_CANVAS_NAME. |
| bool | persistAcrossScenes | When |
Returns
| Type | Description |
|---|---|
| Canvas | The newly created and configured UnityEngine.Canvas component. |
Remarks
The created canvas uses CanvasScaler.ScaleMode.ConstantPixelSize with a
scale factor of 1 for crisp, resolution-independent debug UI. A
GraphicRaycaster is added so pointer events (clicks, scrolls) reach
elements on the canvas.
The canvas GameObject is assigned to the UI layer via AddToUILayer(GameObject).
EnsureEventSystem()
Ensures that exactly one UnityEngine.EventSystems.EventSystem is present in the scene.
If no UnityEngine.EventSystems.EventSystem is found via FindAnyObjectByType, a new
GameObject is created with an UnityEngine.EventSystems.EventSystem component and an
appropriate input module added by Scylla.Core.Util.UI.DebugCanvasUtil.AddInputModule(UnityEngine.GameObject).
Declaration
public static EventSystem EnsureEventSystem()
Returns
| Type | Description |
|---|---|
| EventSystem | The existing UnityEngine.EventSystems.EventSystem if one was already in the scene; otherwise the newly created one. |