# Events

All events fired by the Spark UI system. Subscribe via `SparkEventBus.Subscribe<T>()`.

***

## UIPanelShownEvent

Fired when a UI panel is shown/opened.

| Property    | Type      | Description              |
| ----------- | --------- | ------------------------ |
| `Panel`     | `UIPanel` | The panel that was shown |
| `PanelName` | `string`  | The name of the panel    |

```csharp
SparkEventBus.Subscribe<UIPanelShownEvent>(e =>
{
    Debug.Log($"Panel shown: {e.PanelName}");
});
```

***

## UIPanelHiddenEvent

Fired when a UI panel is hidden/closed.

| Property    | Type      | Description               |
| ----------- | --------- | ------------------------- |
| `Panel`     | `UIPanel` | The panel that was hidden |
| `PanelName` | `string`  | The name of the panel     |

***

## FirstUIPanelOpenedEvent

Fired when the first UI panel is opened from a state where no panels were open. Useful for pausing gameplay or showing cursor.

| Property | Type      | Description                     |
| -------- | --------- | ------------------------------- |
| `Panel`  | `UIPanel` | The first panel that was opened |

***

## AllUIPanelsClosedEvent

Fired when the last open UI panel is closed, returning to a state with no panels open. Useful for resuming gameplay or hiding cursor.

***

## EscapeKeyPressedEvent

Fired when the escape key is pressed, allowing systems to respond to the escape action.

***

## ShowEventMessageEvent

Fired to request displaying an event message on screen (e.g., "Quest Completed", "Level Up").

| Property   | Type     | Description                  |
| ---------- | -------- | ---------------------------- |
| `Message`  | `string` | The message text to display  |
| `Duration` | `float`  | How long to show the message |

***

## CloseAllUIPanelsEvent

Fired to request all UI panels to close. Systems can publish this to force-close all panels.

***

## UISkeletonSpawnedEvent

Fired when the UI skeleton (root UI structure) has been spawned and is ready.

| Property   | Type         | Description                         |
| ---------- | ------------ | ----------------------------------- |
| `Skeleton` | `GameObject` | The spawned UI skeleton root object |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sparkframework.dev/documentation/developer-guide/core-systems/ui-system/events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
