-
Notifications
You must be signed in to change notification settings - Fork 0
Home
title: Home description: Decoupled, simple systems for Unity template: home.html hide:
- navigation
- toc
- Getting-Started-Quick-Start - Define, register, and emit your first message.
- Concepts-Mental-Model - Choose between untargeted, targeted, and broadcast messages.
- Guides-Inspector-Overlay - Use diagnostics and base-call warnings inside Unity.
- Guides-Diagnostics - Inspect emissions, trace paths, and registration topology.
- Architecture-Performance - Read the current published benchmark tables.
openupm add com.wallstop-studios.dxmessaginghttps://github.com/Ambiguous-Interactive/DxMessaging.git
See the Getting-Started-Install for scoped registry, Git URL, and local tarball options.
using DxMessaging.Core.Attributes;
using DxMessaging.Core.Extensions;
using DxMessaging.Unity;
using UnityEngine;
[DxTargetedMessage]
[DxAutoConstructor]
public readonly partial struct DamageRequested
{
public readonly int Amount;
}
public sealed class DamageReceiver : MessageAwareComponent
{
public int Health { get; private set; } = 100;
protected override void RegisterMessageHandlers()
{
base.RegisterMessageHandlers();
_ = Token.RegisterGameObjectTargeted<DamageRequested>(gameObject, OnDamageRequested);
}
private void OnDamageRequested(ref DamageRequested message)
{
Health = Mathf.Max(0, Health - Mathf.Max(0, message.Amount));
}
}
public sealed class Hazard : MonoBehaviour
{
public int Damage = 25;
private void OnTriggerEnter(Collider other)
{
DamageRequested request = new DamageRequested(Damage);
request.EmitGameObjectTargeted(other.gameObject);
}
}On the hazard GameObject, enable Is Trigger on its collider and add a kinematic Rigidbody with
Use Gravity disabled. Put DamageReceiver and the entering collider on the same target
GameObject. The hazard targets that exact object without knowing whether it is a player, enemy,
crate, or future gameplay type. Neither component holds a reference to the other.
Three message shapes - untargeted, targeted, broadcast - and nothing else to learn. Each contract is an explicit typed struct, and no system holds a reference to any other.
Define a struct, register a handler, emit. Registration tokens follow their owner's lifecycle, so handlers remove themselves - no manual unsubscribe, no leaked listeners.
The same simple primitives decouple entire systems. Wiring a feature in is one registration; removing it is deleting that line. Interceptors, handler priorities, and global observers layer on without touching existing code.
Struct messages and by-ref handlers keep steady-state dispatch at zero allocation. Type-indexed routing stays O(1), with published results around 10 ns per handler.
- New to the package: Getting-Started
- Choosing message types: Concepts-Message-Types
- Unity integration patterns: Guides-Unity-Integration
- Debugging message flow: Guides-Diagnostics
- API details: Reference-Reference
- Getting-Started-Overview
- Getting-Started-Getting-Started
- Getting-Started-Install
- Getting-Started-Quick-Start
- Getting-Started-Visual-Guide
- Concepts-Message-Types
- Concepts-Listening-Patterns
- Concepts-Targeting-And-Context
- Concepts-Interceptors-And-Ordering
- Guides-Patterns
- Guides-Unity-Integration
- Guides-Testing
- Guides-Diagnostics
- Guides-Advanced
- Guides-Migration-Guide
- Advanced-Emit-Shorthands
- Advanced-Message-Bus-Providers
- Advanced-Runtime-Configuration
- Advanced-String-Messages
- Reference-Reference
- Reference-Quick-Reference
- Reference-Helpers
- Reference-Faq
- Reference-Glossary
- Reference-Troubleshooting
- Reference-Compatibility
Links