What problem does it solve?
Event systems prevent tight coupling between game systems by letting publishers broadcast changes without knowing subscribers, while also reducing bugs caused by forgotten subscriptions and leaked delegates.
Core Features & Use Cases
- Compare event options: C# events/Action for code-only communication, UnityEvent for designer-wired callbacks, ScriptableObject (SO) event channels for cross-system messaging, and a static EventBus for rare global events.
- Enforce correct lifecycle handling: Subscribe in
OnEnable and unsubscribe in OnDisable to avoid memory leaks across disable/destroy/scene unload.
- Use zero-allocation patterns when needed: Apply special structures for hot paths (e.g., ref-friendly event payloads) rather than allocating per event in performance-critical scenarios.
- Common mistakes prevention: Avoid subscribing in
Start/Awake without guaranteed cleanup, avoid using events where a direct method call is simpler, and avoid overusing global event buses.
Quick Start
Use the event-systems skill to pick the right Unity event pattern for your publisher-subscriber need, then implement symmetric subscribe/unsubscribe in OnEnable/OnDisable to keep your scene transitions leak-free.