event-bus-system

Implement a global decoupled Event Bus for Unity with struct-based events.

71|11|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/nlelouche/Unity-SkillForge --skill event-bus-system
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: event-bus-system
Source: https://github.com/nlelouche/Unity-SkillForge/tree/main/.agent/skills/01-architecture/event-bus-system
Command: npx skills add https://github.com/nlelouche/Unity-SkillForge --skill event-bus-system

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill addresses the challenge of tight coupling between different systems in a Unity project, which can lead to complex dependencies and difficulties in maintenance and scaling. It provides a robust, decoupled communication channel.

Core Features & Use Cases

  • Global Decoupled Communication: Enables systems to communicate without direct references using a publish-subscribe pattern.
  • Zero-Allocation Events: Utilizes struct-based events to prevent garbage collection spikes during gameplay, crucial for performance-sensitive applications.
  • Use Case: When the player takes damage, the PlayerHealth system can publish a PlayerDamagedEvent. The UI system can subscribe to this event to update the health bar, and an analytics system can subscribe to log the damage event, all without direct knowledge of each other.

Quick Start

Use the event-bus-system skill to publish a new 'PlayerDamagedEvent' with 'DamageAmount' set to 10.0.

Frequently Asked Questions about event-bus-system

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I decouple Unity systems using an event bus without causing garbage collection spikes?

You can decouple Unity systems by implementing a global event bus using struct-based events and a publish-subscribe model. This approach ensures zero garbage collection allocations during critical gameplay paths.

What is the best way to implement an observer pattern in Unity for performance-sensitive applications?

The best way to implement the observer pattern in Unity is using a zero-allocation event bus with struct-based events. This prevents GC spikes while facilitating decoupled communication between disparate game systems.

Can I use struct-based events for decoupled communication in my Unity project?

Yes, you can define custom event structs and use an abstract base class for easy listener implementation. This allows disparate systems to communicate through a global publish-subscribe channel without direct references.

How do I publish a custom event like PlayerDamagedEvent to update my UI and analytics systems?

You publish a custom event struct containing the necessary data, like DamageAmount, to a global event bus. Disparate systems such as UI and analytics can subscribe to this event and react independently without knowing each other.

Does this event bus system support zero garbage collection allocations in critical paths?

Yes, the event bus system is optimized for zero garbage collection allocations by utilizing struct-based events. This is crucial for preventing performance drops in performance-sensitive Unity applications.