-
Notifications
You must be signed in to change notification settings - Fork 0
Reference Troubleshooting
github-actions[bot] edited this page Jun 26, 2026
·
6 revisions
..-Getting-Started | Faq | ..-Getting-Started-Getting-Started | Glossary
- Ensure your
MessageRegistrationTokenis enabled (Enable inOnEnable, Disable inOnDisable). - Verify the category matches the emission (Untargeted vs Targeted vs Broadcast).
- Targeted/Broadcast require a valid
InstanceId; ensure the target/source object exists when you emit. - In Unity, confirm your
MessagingComponentexists on sender/receiver GameObjects. -
CRITICAL: If inheriting from
MessageAwareComponent, ensure your overrides call base methods:-
base.RegisterMessageHandlers()- Call this FIRST in your override to preserve default setup (including string message demos) and parent class registrations. -
base.Awake()- Call this if you overrideAwake(), or your token won't be created (this is the #1 cause of handlers not firing). -
base.OnEnable()/base.OnDisable()- Call these so the token actually enables/disables. -
base.OnDestroy()- Call this if you overrideOnDestroy(), or registrations leak past the component's lifetime and held references prevent GC. -
Never use
newto hide Unity methods (e.g.,new void OnEnable()); always useoverrideand callbase.*. - For the complete table of guarded methods and the exact failure mode for each, see ..-Getting-Started-Quick-Start#important-inheritance-and-base-calls in the quickstart.
-
-
ALWAYS register message handlers in
Awake(), notStart(). -
MessageAwareComponentautomatically callsRegisterMessageHandlers()inAwake(). - Registering in
Awake()ensures handlers are ready before other components'Start()methods run. - If you register in
Start(), you may miss messages emitted by other components in theirStart()methods.
- Check
priorityvalues on registrations; lower runs earlier. Same priority is registration order. - Interceptors always precede handlers and can cancel; confirm interceptors return
true.
- Avoid calling stage/enable multiple times; pair registrations and lifecycles consistently.
- Review logs with
bus.Log.Enabled = trueto see the registration history.
- Prefer struct messages implementing the generic interfaces:
I*Message<T>. - Use by-ref handler overloads to avoid copies.
- Register handlers once in
Awake/setup, not every frame: each registration allocates a small bounded amount, while steady-state dispatch is allocation-free. See the Faq#does-dxmessaging-allocate-memory-is-dispatch-zero-gc.
- If you need to emit when a component is disabled, use a bus not tied to enable state or set
emitMessagesWhenDisabledonMessagingComponent.
- Diagnostics are off by default. Leave them off in release builds (
IMessageBus.GlobalDiagnosticsTargets = DiagnosticsTarget.Off); enable them only when inspecting message history. See ..-Guides-Diagnostics.
- Mark the message type
partial. The generator emits members into a second partial declaration, which requires the keyword on your type. - Apply a
[DxUntargetedMessage],[DxTargetedMessage], or[DxBroadcastMessage]attribute, or implement the matchingI*Messageinterface directly. - An assembly definition is not required -- generation runs for Unity's default
Assembly-CSharpas well as for your own.asmdefassemblies. - After changing message types, let Unity finish recompiling; generated members appear once the analyzer reruns.
- Read
bus.OccupiedTypeSlotsandbus.OccupiedTargetSlots(or the globalMessageHandler.MessageBus.OccupiedTypeSlots/OccupiedTargetSlots) at region boundaries to see whether per-type or per-target slots are the culprit. - Call
MessageHandler.TrimAll(force: true)(orbus.Trim(force: true)) at scene unload or other natural transitions. Slots that survive a forced trim correspond to active registrations. - Tune the reclamation policy through
DxMessagingRuntimeSettings. See the ..-Guides-Memory-Reclamation for tuning recommendations and a leak-watching pattern.
-
Get Unstuck
- to Faq -- Common questions answered
- to ..-Getting-Started-Getting-Started -- Learn the basics
- to Glossary -- Understand the terminology
-
Debug & Inspect
- to ..-Guides-Diagnostics -- Inspector tools and debugging
- to ..-Concepts-Listening-Patterns -- Verify you're listening correctly
- to ..-Concepts-Message-Types -- Ensure you're using the right type
-
Examples
- to Mini Combat sample -- See working code
- to ..-Guides-Patterns -- Real-world solutions
- 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