API

Assembly: Spark.UI

The UI plugin does not expose a central interface. Instead, it provides base classes and utility components for building game UI.

GamePanel

Abstract MonoBehaviour base class for all UI panels. Handles open/close state, visibility, and cross-panel coordination.

Fields

Field
Type
Description

panelCanvasGroup

CanvasGroup

Controls alpha, interactable, blocksRaycasts

onPanelOpenedEvent

UnityEvent

Invoked when panel opens

onPanelClosedEvent

UnityEvent

Invoked when panel closes

Methods

virtual void OpenPanel()
// Shows the panel. Sets CanvasGroup alpha to 1, interactable and
// blocksRaycasts to true. Checks the "DEAD" rule and blocks opening
// if the player is dead. Sets the "UI_OPENED" rule to true.

virtual void ClosePanel()
// Hides the panel. Sets CanvasGroup alpha to 0, interactable and
// blocksRaycasts to false. Updates "UI_OPENED" rule.

bool IsOpen { get; }
// Returns current open state.

virtual void OnPanelOpened()
// Override hook called after the panel opens.

virtual void OnPanelClosed()
// Override hook called after the panel closes.

static int GetOpenPanelCount()
// Returns how many panels are currently open.

static bool AnyPanelOpen()
// True if at least one panel is open.

static bool AnyOtherPanelOpen(GamePanel excludePanel)
// True if any panel besides the given one is open.

static void CloseAllOtherPanels(GamePanel excludePanel)
// Closes all panels except the specified one.

GamePanel implements ISparkEventHandler<CloseAllUIPanelsEvent> and closes itself when the event is published.

SparkUISpawner

MonoBehaviour that dynamically instantiates UI prefabs at runtime.

Fields

Field
Type
Description

uiPrefab

RectTransform

Prefab to spawn

instantiateAsChild

bool

If true, spawns as child; if false, spawns as sibling

Methods

CursorManager

MonoBehaviour that dynamically switches the cursor based on what the player is hovering over.

Fields

Field
Type
Description

defaultCursor

CursorOptionData

Fallback cursor

availableCursors

List<CursorOptionData>

All registered cursors

maxRaycastDistance

float

How far to raycast

raycastLayerMask

LayerMask

Which layers to check

Methods

Uses priority-based cursor selection. Objects implementing ICursorProvider can provide their own cursor when hovered.

ICursorProvider

Interface for objects that provide a custom cursor on hover.

CursorOptionData

ScriptableObject defining a cursor appearance.

Field
Type
Description

cursorId

string

Unique identifier

cursorTexture

Texture2D

Cursor image

hotspot

Vector2

Click point offset

priority

int

Selection priority (higher wins)

GenericTooltipData

Simple data container for tooltip content.

Field
Type
Description

icon

Sprite

Optional icon

title

string

Optional title

description

string

Optional description

Properties: HasIcon, HasTitle, HasDescription

Events

CloseAllUIPanelsEvent

Published to close all open panels at once.

Property
Type
Description

RequestSource

GameObject

Who requested the close

EventType: "CloseAllUIPanels"

Usage

Creating a Custom Panel

Implementing ICursorProvider

Closing All Panels

Last updated

Was this helpful?