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
- Define Signal IDs: Go to Dashboard > Settings (or the Signal data file directly if manually editing). Add IDs like
GameStart,PlayerDied,ScoreUpdated. - Send: Use a
HookSignalSendercomponent or code. - Listen: Use a
HookSignalListenercomponent 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'sOnClickevent.
HookSignalListener
Attaches to a GameObject.
- Signal ID: Which signal to listen for.
- Response: A
UnityEventthat 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") { ... }
}