> For the complete documentation index, see [llms.txt](https://docs.sparkframework.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sparkframework.dev/documentation/developer-guide/core-systems/ui-system/events.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
