Skip to main content

Signal System

HookUI provides a built-in "Event Bus" called Signals. Ideally, your UI should never directly reference your Gameplay scripts (e.g., PlayerController.Jump()), and vice-versa.

How it Works

  1. Define Signal IDs: Go to Dashboard > Settings (or the Signal data file directly if manually editing). Add IDs like GameStart, PlayerDied, ScoreUpdated.
  2. Send: Use a HookSignalSender component or code.
  3. Listen: Use a HookSignalListener component or code.

Components

HookSignalSender

Attaches to a GameObject.

  • Signal ID: Which signal to send.
  • Triggers: Can auto-send on Start, OnEnable, OnDisable.
  • Public Method: Send() can be wired to a Button's OnClick event.

HookSignalListener

Attaches to a GameObject.

  • Signal ID: Which signal to listen for.
  • Response: A UnityEvent that fires when the signal is caught.

Code API

// Sending
HookSignalHub.Send("GameStart");

// Listening
void OnEnable() {
HookSignalHub.OnSignal += HandleSignal;
}
void HandleSignal(string id) {
if (id == "GameStart") { ... }
}