DxMessaging Documentation¶
DxMessaging is a high-performance, type-safe messaging library for Unity that provides a clean, decoupled communication pattern between game components.
Why DxMessaging?¶
- High Performance -- Zero-allocation message dispatch with pooled handlers
- Type-Safe -- Compile-time message type checking prevents runtime errors
- Decoupled Architecture -- Components communicate without direct references
- Flexible Targeting -- Untargeted, Targeted, and Broadcast message patterns
- Unity-Native -- Built specifically for Unity with MonoBehaviour integration
Quick Links¶
- Mental Model -- How to think about DxMessaging
- Visual Guide -- Beginner-friendly introduction with diagrams
- Quick Start -- Your first message in 5 minutes
- Message Types -- Untargeted, Targeted, Broadcast patterns
- API Reference -- Complete API documentation
Installation¶
Via OpenUPM (Recommended)¶
Or via Git URL¶
See the Install Guide for all options including NPM scoped registries and local tarballs.
Quick Example¶
C#
// Define a message
public readonly struct DamageMessage : IUntargetedMessage
{
public readonly int amount;
public DamageMessage(int amount) => this.amount = amount;
}
// Subscribe and handle (using a MessageRegistrationToken)
_ = Token.RegisterUntargeted<DamageMessage>(msg =>
Debug.Log($"Received {msg.amount} damage!"));
// Emit the message
DamageMessage damage = new DamageMessage(25);
damage.EmitUntargeted();