com.wallstop-studios.dxmessaging 2.0.0-rc27.3.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/.github/workflows/format-on-demand.yml +2 -2
  2. package/.github/workflows/json-format-check.yml +1 -1
  3. package/.github/workflows/markdown-json.yml +1 -1
  4. package/.github/workflows/markdownlint.yml +1 -1
  5. package/.github/workflows/npm-publish.yml +1 -1
  6. package/.github/workflows/prettier-autofix.yml +2 -2
  7. package/.github/workflows/yaml-format-lint.yml +1 -1
  8. package/Docs/Advanced.md +26 -1
  9. package/Docs/Comparisons.md +1352 -141
  10. package/Docs/Compatibility.md +27 -0
  11. package/Docs/DesignAndArchitecture.md +41 -34
  12. package/Docs/EmitShorthands.md +34 -0
  13. package/Docs/GettingStarted.md +84 -17
  14. package/Docs/Helpers.md +1 -1
  15. package/Docs/Index.md +28 -25
  16. package/Docs/Install.md +29 -6
  17. package/Docs/Integrations/Reflex.md +292 -0
  18. package/Docs/Integrations/Reflex.md.meta +7 -0
  19. package/Docs/Integrations/VContainer.md +324 -0
  20. package/Docs/Integrations/VContainer.md.meta +7 -0
  21. package/Docs/Integrations/Zenject.md +333 -0
  22. package/Docs/Integrations/Zenject.md.meta +7 -0
  23. package/{Editor/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.pdb.meta → Docs/Integrations.meta} +2 -1
  24. package/Docs/InterceptorsAndOrdering.md +371 -17
  25. package/Docs/ListeningPatterns.md +206 -0
  26. package/Docs/MessageBusProviders.md +496 -0
  27. package/Docs/MessageBusProviders.md.meta +7 -0
  28. package/Docs/MessageTypes.md +27 -0
  29. package/Docs/MigrationGuide.md +45 -0
  30. package/Docs/Overview.md +114 -20
  31. package/Docs/Patterns.md +327 -2
  32. package/Docs/Performance.md +9 -9
  33. package/Docs/QuickReference.md +31 -0
  34. package/Docs/RuntimeConfiguration.md +407 -0
  35. package/Docs/RuntimeConfiguration.md.meta +7 -0
  36. package/Docs/UnityIntegration.md +3 -1
  37. package/Docs/VisualGuide.md +281 -167
  38. package/Editor/Analyzers/Microsoft.CodeAnalysis.CSharp.dll +0 -0
  39. package/Editor/Analyzers/Microsoft.CodeAnalysis.CSharp.dll.meta +3 -3
  40. package/Editor/Analyzers/Microsoft.CodeAnalysis.dll +0 -0
  41. package/Editor/Analyzers/Microsoft.CodeAnalysis.dll.meta +2 -2
  42. package/Editor/Analyzers/System.Collections.Immutable.dll +0 -0
  43. package/Editor/Analyzers/System.Reflection.Metadata.dll +0 -0
  44. package/Editor/Analyzers/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  45. package/Editor/CustomEditors/MessagingComponentEditor.cs +15 -6
  46. package/README.md +388 -67
  47. package/Runtime/AssemblyInfo.cs +4 -0
  48. package/Runtime/Core/Extensions/MessageBusExtensions.cs +253 -0
  49. package/Runtime/Core/Extensions/MessageBusExtensions.cs.meta +12 -0
  50. package/Runtime/Core/Extensions/MessageExtensions.cs +137 -89
  51. package/Runtime/Core/MessageBus/GlobalMessageBusProvider.cs +23 -0
  52. package/Runtime/Core/MessageBus/GlobalMessageBusProvider.cs.meta +11 -0
  53. package/Runtime/Core/MessageBus/IMessageBusProvider.cs +14 -0
  54. package/Runtime/Core/MessageBus/IMessageBusProvider.cs.meta +11 -0
  55. package/Runtime/Core/MessageBus/IMessageRegistrationBuilder.cs +18 -0
  56. package/Runtime/Core/MessageBus/IMessageRegistrationBuilder.cs.meta +11 -0
  57. package/Runtime/Core/MessageBus/MessageBusRebindMode.cs +26 -0
  58. package/Runtime/Core/MessageBus/MessageBusRebindMode.cs.meta +11 -0
  59. package/Runtime/Core/MessageBus/MessageRegistrationBuilder.cs +383 -0
  60. package/Runtime/Core/MessageBus/MessageRegistrationBuilder.cs.meta +11 -0
  61. package/Runtime/Core/MessageHandler.cs +198 -27
  62. package/Runtime/Core/MessageRegistrationToken.cs +67 -25
  63. package/Runtime/Unity/CurrentGlobalMessageBusProvider.cs +31 -0
  64. package/Runtime/Unity/CurrentGlobalMessageBusProvider.cs.meta +12 -0
  65. package/Runtime/Unity/InitialGlobalMessageBusProvider.cs +38 -0
  66. package/Runtime/Unity/InitialGlobalMessageBusProvider.cs.meta +12 -0
  67. package/Runtime/Unity/Integrations/Reflex/AssemblyInfo.cs +11 -0
  68. package/Runtime/Unity/Integrations/Reflex/AssemblyInfo.cs.meta +3 -0
  69. package/Runtime/Unity/Integrations/Reflex/ReflexRegistrationInstaller.cs +73 -0
  70. package/Runtime/Unity/Integrations/Reflex/ReflexRegistrationInstaller.cs.meta +11 -0
  71. package/Runtime/Unity/Integrations/Reflex/WallstopStudios.DxMessaging.Reflex.asmdef +20 -0
  72. package/Runtime/Unity/Integrations/Reflex/WallstopStudios.DxMessaging.Reflex.asmdef.meta +7 -0
  73. package/Runtime/Unity/Integrations/Reflex.meta +8 -0
  74. package/Runtime/Unity/Integrations/VContainer/AssemblyInfo.cs +11 -0
  75. package/Runtime/Unity/Integrations/VContainer/AssemblyInfo.cs.meta +3 -0
  76. package/Runtime/Unity/Integrations/VContainer/VContainerRegistrationExtensions.cs +46 -0
  77. package/Runtime/Unity/Integrations/VContainer/VContainerRegistrationExtensions.cs.meta +11 -0
  78. package/Runtime/Unity/Integrations/VContainer/WallstopStudios.DxMessaging.VContainer.asmdef +30 -0
  79. package/Runtime/Unity/Integrations/VContainer/WallstopStudios.DxMessaging.VContainer.asmdef.meta +7 -0
  80. package/Runtime/Unity/Integrations/VContainer.meta +8 -0
  81. package/Runtime/Unity/Integrations/Zenject/AssemblyInfo.cs +11 -0
  82. package/Runtime/Unity/Integrations/Zenject/AssemblyInfo.cs.meta +3 -0
  83. package/Runtime/Unity/Integrations/Zenject/WallstopStudios.DxMessaging.Zenject.asmdef +30 -0
  84. package/Runtime/Unity/Integrations/Zenject/WallstopStudios.DxMessaging.Zenject.asmdef.meta +7 -0
  85. package/Runtime/Unity/Integrations/Zenject/ZenjectRegistrationInstaller.cs +55 -0
  86. package/Runtime/Unity/Integrations/Zenject/ZenjectRegistrationInstaller.cs.meta +11 -0
  87. package/Runtime/Unity/Integrations/Zenject.meta +8 -0
  88. package/Runtime/Unity/Integrations.meta +8 -0
  89. package/Runtime/Unity/MessageAwareComponent.cs +102 -0
  90. package/Runtime/Unity/MessageBusProviderHandle.cs +97 -0
  91. package/Runtime/Unity/MessageBusProviderHandle.cs.meta +12 -0
  92. package/Runtime/Unity/MessagingComponent.cs +164 -2
  93. package/Runtime/Unity/MessagingComponentInstaller.cs +120 -0
  94. package/Runtime/Unity/MessagingComponentInstaller.cs.meta +12 -0
  95. package/Runtime/Unity/ScriptableMessageBusProvider.cs +14 -0
  96. package/Runtime/Unity/ScriptableMessageBusProvider.cs.meta +12 -0
  97. package/Samples~/DI/Prefabs/MessagingInstallerSample.prefab +98 -0
  98. package/Samples~/DI/Prefabs/MessagingInstallerSample.prefab.meta +7 -0
  99. package/Samples~/DI/Prefabs.meta +8 -0
  100. package/Samples~/DI/Providers/GlobalMessageBusProvider.asset +14 -0
  101. package/Samples~/DI/Providers/GlobalMessageBusProvider.asset.meta +8 -0
  102. package/Samples~/DI/Providers/InitialGlobalMessageBusProvider.asset +14 -0
  103. package/Samples~/DI/Providers/InitialGlobalMessageBusProvider.asset.meta +8 -0
  104. package/Samples~/DI/Providers.meta +8 -0
  105. package/Samples~/DI/README.md +51 -0
  106. package/Samples~/DI/README.md.meta +7 -0
  107. package/Samples~/DI/Reflex/SampleInstaller.cs +75 -0
  108. package/Samples~/DI/Reflex/SampleInstaller.cs.meta +11 -0
  109. package/Samples~/DI/Reflex.meta +8 -0
  110. package/Samples~/DI/VContainer/SampleLifetimeScope.cs +81 -0
  111. package/Samples~/DI/VContainer/SampleLifetimeScope.cs.meta +11 -0
  112. package/Samples~/DI/VContainer.meta +8 -0
  113. package/Samples~/DI/Zenject/SampleInstaller.cs +67 -0
  114. package/Samples~/DI/Zenject/SampleInstaller.cs.meta +11 -0
  115. package/Samples~/DI/Zenject.meta +8 -0
  116. package/Samples~/DI.meta +8 -0
  117. package/Samples~/Mini Combat/README.md +86 -28
  118. package/Samples~/Mini Combat/Walkthrough.md +41 -25
  119. package/Samples~/UI Buttons + Inspector/DiagnosticsEnabler.cs +12 -2
  120. package/Samples~/UI Buttons + Inspector/README.md +55 -12
  121. package/Samples~/UI Buttons + Inspector/README.md.meta +7 -0
  122. package/Tests/Runtime/Benchmarks/BenchmarkSession.cs +444 -0
  123. package/Tests/Runtime/Benchmarks/BenchmarkSession.cs.meta +11 -0
  124. package/Tests/Runtime/Benchmarks/BenchmarkTestBase.cs +94 -0
  125. package/Tests/Runtime/Benchmarks/BenchmarkTestBase.cs.meta +11 -0
  126. package/Tests/Runtime/Benchmarks/ComparisonPerformanceTests.cs +395 -0
  127. package/Tests/Runtime/Benchmarks/ComparisonPerformanceTests.cs.meta +11 -0
  128. package/Tests/Runtime/Benchmarks/PerformanceTests.cs +77 -429
  129. package/Tests/Runtime/Benchmarks/ProviderResolutionBenchmarks.cs +142 -0
  130. package/Tests/Runtime/Benchmarks/ProviderResolutionBenchmarks.cs.meta +12 -0
  131. package/Tests/Runtime/Benchmarks/WallstopStudios.DxMessaging.Tests.Runtime.Benchmarks.asmdef +50 -0
  132. package/Tests/Runtime/Benchmarks/WallstopStudios.DxMessaging.Tests.Runtime.Benchmarks.asmdef.meta +7 -0
  133. package/Tests/Runtime/Core/DefaultBusFallbackTests.cs +333 -0
  134. package/Tests/Runtime/Core/DefaultBusFallbackTests.cs.meta +11 -0
  135. package/Tests/Runtime/Core/Extensions/MessageBusExtensionsTests.cs +278 -0
  136. package/Tests/Runtime/Core/Extensions/MessageBusExtensionsTests.cs.meta +11 -0
  137. package/Tests/Runtime/Core/Extensions/MessageExtensionsProviderTests.cs +289 -0
  138. package/Tests/Runtime/Core/Extensions/MessageExtensionsProviderTests.cs.meta +11 -0
  139. package/Tests/Runtime/Core/Extensions.meta +8 -0
  140. package/Tests/Runtime/Core/IntegrationShimSmokeTests.cs +57 -0
  141. package/Tests/Runtime/Core/IntegrationShimSmokeTests.cs.meta +11 -0
  142. package/Tests/Runtime/Core/MessageHandlerGlobalBusTests.cs +219 -0
  143. package/Tests/Runtime/Core/MessageHandlerGlobalBusTests.cs.meta +11 -0
  144. package/Tests/Runtime/Core/MessageRegistrationBuilderTests.cs +204 -0
  145. package/Tests/Runtime/Core/MessageRegistrationBuilderTests.cs.meta +11 -0
  146. package/Tests/Runtime/Core/MessagingTestBase.cs +4 -4
  147. package/Tests/Runtime/Core/NominalTests.cs +2 -2
  148. package/Tests/Runtime/Core/SourceGeneratorNestedTests.cs +1 -1
  149. package/Tests/Runtime/Core/TypedShorthandTests.cs +2 -2
  150. package/Tests/Runtime/Core/UntargetedEquivalenceTests.cs +1 -1
  151. package/Tests/Runtime/Core/UntargetedPrefreezeTests.cs +2 -4
  152. package/Tests/Runtime/Integrations/Reflex/ReflexIntegrationTests.cs +162 -0
  153. package/Tests/Runtime/Integrations/Reflex/ReflexIntegrationTests.cs.meta +11 -0
  154. package/Tests/Runtime/Integrations/Reflex/Resources/ReflexSettings.asset +16 -0
  155. package/Tests/Runtime/Integrations/Reflex/Resources/ReflexSettings.asset.meta +8 -0
  156. package/Tests/Runtime/Integrations/Reflex/Resources.meta +8 -0
  157. package/Tests/Runtime/Integrations/Reflex/WallstopStudios.DxMessaging.Tests.Runtime.Reflex.asmdef +27 -0
  158. package/Tests/Runtime/Integrations/Reflex/WallstopStudios.DxMessaging.Tests.Runtime.Reflex.asmdef.meta +7 -0
  159. package/Tests/Runtime/Integrations/Reflex.meta +8 -0
  160. package/Tests/Runtime/Integrations/VContainer/VContainerIntegrationTests.cs +140 -0
  161. package/Tests/Runtime/Integrations/VContainer/VContainerIntegrationTests.cs.meta +11 -0
  162. package/Tests/Runtime/Integrations/VContainer/WallstopStudios.DxMessaging.Tests.Runtime.VContainer.asmdef +37 -0
  163. package/Tests/Runtime/Integrations/VContainer/WallstopStudios.DxMessaging.Tests.Runtime.VContainer.asmdef.meta +7 -0
  164. package/Tests/Runtime/Integrations/VContainer.meta +8 -0
  165. package/Tests/Runtime/Integrations/Zenject/WallstopStudios.DxMessaging.Tests.Runtime.Zenject.asmdef +37 -0
  166. package/Tests/Runtime/Integrations/Zenject/WallstopStudios.DxMessaging.Tests.Runtime.Zenject.asmdef.meta +7 -0
  167. package/Tests/Runtime/Integrations/Zenject/ZenjectIntegrationTests.cs +140 -0
  168. package/Tests/Runtime/Integrations/Zenject/ZenjectIntegrationTests.cs.meta +11 -0
  169. package/Tests/Runtime/Integrations/Zenject.meta +8 -0
  170. package/Tests/Runtime/Integrations.meta +8 -0
  171. package/Tests/Runtime/Scripts/Components/EmptyMessageAwareComponent.cs +1 -1
  172. package/Tests/Runtime/Scripts/Components/GenericMessageAwareComponent.cs +1 -1
  173. package/Tests/Runtime/Scripts/Components/SimpleMessageAwareComponent.cs +1 -1
  174. package/Tests/Runtime/TestUtilities/UnityFixtureBase.cs +64 -0
  175. package/Tests/Runtime/TestUtilities/UnityFixtureBase.cs.meta +12 -0
  176. package/Tests/Runtime/TestUtilities.meta +9 -0
  177. package/Tests/Runtime/Unity/MessageBusProviderAssetTests.cs +57 -0
  178. package/Tests/Runtime/Unity/MessageBusProviderAssetTests.cs.meta +11 -0
  179. package/Tests/Runtime/Unity/MessageBusProviderHandleTests.cs +107 -0
  180. package/Tests/Runtime/Unity/MessageBusProviderHandleTests.cs.meta +12 -0
  181. package/Tests/Runtime/Unity/MessagingComponentProviderIntegrationTests.cs +210 -0
  182. package/Tests/Runtime/Unity/MessagingComponentProviderIntegrationTests.cs.meta +12 -0
  183. package/Tests/Runtime/Unity.meta +9 -0
  184. package/Tests/Runtime/WallstopStudios.DxMessaging.Tests.Runtime.asmdef +3 -1
  185. package/package.json +1 -1
@@ -15,3 +15,30 @@ Notes
15
15
 
16
16
  - RP‑agnostic: DxMessaging does not depend on rendering APIs; it works equally across Built‑In, URP, and HDRP.
17
17
  - Minimum version is governed by the package manifest (`unity`: 2021.3). Newer LTS versions are expected to work.
18
+
19
+ ## Architecture Pattern Compatibility
20
+
21
+ ### Scriptable Object Architecture (SOA)
22
+
23
+ DxMessaging can work alongside Scriptable Object Architecture patterns, though SOA has documented limitations. See [Pattern 14: SOA Compatibility](Patterns.md#14-compatibility-with-scriptable-object-architecture-soa) for detailed integration strategies, code examples, and migration paths.
24
+
25
+ #### Quick summary
26
+
27
+ - ✅ **Compatible** - DxMessaging can bridge with SOA systems
28
+ - ⚠️ **Not recommended** - SOA has scalability and maintainability concerns ([detailed critique](https://github.com/cathei/AntiScriptableObjectArchitecture))
29
+ - ✅ **Best practice** - Use ScriptableObjects for immutable design data, DxMessaging for runtime events
30
+ - → See [SOA Integration Patterns](Patterns.md#14-compatibility-with-scriptable-object-architecture-soa) for three coexistence strategies with code examples
31
+
32
+ ### Dependency Injection (DI) Frameworks
33
+
34
+ DxMessaging integrates seamlessly with popular DI frameworks:
35
+
36
+ - **Zenject** - See [Zenject Integration Guide](Integrations/Zenject.md)
37
+ - **VContainer** - See [VContainer Integration Guide](Integrations/VContainer.md)
38
+ - **Reflex** - See [Reflex Integration Guide](Integrations/Reflex.md)
39
+
40
+ DI and DxMessaging complement each other: DI manages dependencies/services, DxMessaging handles event communication.
41
+
42
+ ### Other Unity Frameworks
43
+
44
+ For comparisons with other messaging/event frameworks (UniRx, MessagePipe, Zenject Signals, etc.), see [Framework Comparisons](Comparisons.md).
@@ -49,42 +49,49 @@ DxMessaging was built with these principles:
49
49
 
50
50
  ## Architecture Overview
51
51
 
52
- ```text
53
- ┌─────────────────────────────────────────────────────────────┐
54
- │ Application │
55
- │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
56
- │ │ Component A │ │ Component B │ │ Component C │ │
57
- │ │ │ │ │ │ │ │
58
- │ │ Token.Reg() │ │ Token.Reg() │ │ Token.Reg() │ │
59
- │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
60
- │ │ │ │ │
61
- │ └─────────────────┼─────────────────┘ │
62
- │ ▼ │
63
- │ ┌─────────────────────────┐ │
64
- │ │ MessageRegistrationToken│ │
65
- │ │ │ │
66
- │ │ Stages registrations │ │
67
- │ │ • Enable/Disable │ │
68
- │ │ • Lifecycle management │ │
69
- │ └────────────┬────────────┘ │
70
- │ ▼ │
71
- │ ┌─────────────────────────┐ │
72
- │ │ MessageHandler │ │
73
- │ │ │ │
74
- │ │ Per-component handler │ │
75
- │ │ Active/Inactive state │ │
76
- │ └────────────┬────────────┘ │
77
- │ ▼ │
78
- │ ┌─────────────────────────┐ │
79
- │ │ MessageBus │ │
80
- │ │ │ │
81
- │ │ Interceptors │ │
82
- │ │ Handlers │ │
83
- │ │ Post-Processors │ │
84
- │ └─────────────────────────┘ │
85
- └─────────────────────────────────────────────────────────────┘
52
+ ```mermaid
53
+ %%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#fff','primaryTextColor':'#000','primaryBorderColor':'#000','lineColor':'#2563eb','secondaryColor':'#fff','tertiaryColor':'#fff','edgeLabelBackground':'#fff'}}}%%
54
+ flowchart TB
55
+ subgraph App["<b>Application Layer</b>"]
56
+ CompA[Component A<br/>Token.Reg]
57
+ CompB[Component B<br/>Token.Reg]
58
+ CompC[Component C<br/>Token.Reg]
59
+ end
60
+
61
+ subgraph Token["<b>Registration Layer</b>"]
62
+ MRT[MessageRegistrationToken<br/>• Stages registrations<br/>• Enable/Disable<br/>• Lifecycle management]
63
+ end
64
+
65
+ subgraph Handler["<b>Handler Layer</b>"]
66
+ MH[MessageHandler<br/>• Per-component handler<br/>• Active/Inactive state]
67
+ end
68
+
69
+ subgraph Bus["<b>Message Bus Layer</b>"]
70
+ MB[MessageBus<br/>• Interceptors<br/>• Handlers<br/>• Post-Processors]
71
+ end
72
+
73
+ CompA ==> MRT
74
+ CompB ==> MRT
75
+ CompC ==> MRT
76
+ MRT ==> MH
77
+ MH ==> MB
78
+
79
+ style App fill:#bae7ff,stroke:#0050b3,stroke-width:3px,color:#000
80
+ style Token fill:#ffe7ba,stroke:#d48806,stroke-width:3px,color:#000
81
+ style Handler fill:#d3adf7,stroke:#531dab,stroke-width:3px,color:#000
82
+ style Bus fill:#b7eb8f,stroke:#389e0d,stroke-width:3px,color:#000
83
+ style MRT fill:#ffe7ba,stroke:#d48806,stroke-width:2px,color:#000
84
+ style MH fill:#d3adf7,stroke:#531dab,stroke-width:2px,color:#000
85
+ style MB fill:#b7eb8f,stroke:#389e0d,stroke-width:2px,color:#000
86
86
  ```
87
87
 
88
+ ### Layer Responsibilities
89
+
90
+ 1. **Application Layer** - Your Unity components register message handlers
91
+ 1. **Registration Layer** - Token manages handler lifecycle (enable/disable/cleanup)
92
+ 1. **Handler Layer** - Per-component state management (active/inactive)
93
+ 1. **Message Bus Layer** - Routes messages through interceptors → handlers → post-processors
94
+
88
95
  ## Performance Optimizations
89
96
 
90
97
  - Struct messages passed by `ref` to avoid copying and GC.
@@ -45,6 +45,40 @@ var damage = new TookDamage(5);
45
45
  damage.EmitFrom(enemy); // Broadcast: listeners interested in enemy damage receive this
46
46
  ```
47
47
 
48
+ ### Bus-First Helpers
49
+
50
+ Prefer injecting `IMessageBus` (or `IMessageRegistrationBuilder`) in DI scenarios and use the bus-first extensions for parity with the shorthands:
51
+
52
+ ```csharp
53
+ using DxMessaging.Core.Extensions;
54
+ using DxMessaging.Core.Attributes;
55
+
56
+ public sealed class ScoreReporter
57
+ {
58
+ private readonly IMessageBus messageBus;
59
+
60
+ public ScoreReporter(IMessageBus messageBus)
61
+ {
62
+ this.messageBus = messageBus;
63
+ }
64
+
65
+ public void Report(int value)
66
+ {
67
+ ScoreChanged message = new ScoreChanged(value);
68
+ messageBus.EmitUntargeted(ref message);
69
+ }
70
+ }
71
+
72
+ [DxUntargetedMessage]
73
+ public readonly struct ScoreChanged
74
+ {
75
+ public readonly int Value;
76
+ public ScoreChanged(int value) => Value = value;
77
+ }
78
+ ```
79
+
80
+ These helpers mirror the struct/class/targeted/broadcast overloads available on message instances. They keep DI-friendly services aligned with the same dispatch path as Unity shorthands.
81
+
48
82
  ## Understanding Each Shorthand
49
83
 
50
84
  ### `Emit()` — Global Broadcast (Untargeted)
@@ -27,13 +27,31 @@ By the end of this guide, you will:
27
27
 
28
28
  ## What is DxMessaging?
29
29
 
30
- DxMessaging is a high‑performance, type‑safe messaging system for Unity. It replaces sprawling C# events, brittle UnityEvents, and ad‑hoc global buses with clean, observable, and predictable communication.
30
+ **Picture this:** You're building a Unity game. Your player takes damage. Now you need to:
31
31
 
32
- Think of it as the event system you wish Unity had built‑in:
32
+ - Update the health bar UI
33
+ - Play a damage sound
34
+ - Show a damage number popup
35
+ - Track damage for analytics
36
+ - Check if an achievement unlocked
37
+ - Maybe trigger a tutorial tip
33
38
 
34
- - Decoupled systems without manual subscribe/unsubscribe headaches
35
- - Predictable execution order with powerful interception and diagnostics
36
- - Scales from prototypes to large production codebases
39
+ **The old way:** The Player script needs references to all 6 systems. Or they all need references to the Player. It's a tangled mess.
40
+
41
+ **The DxMessaging way:** The Player emits one message: `TookDamage(25)`. Everyone who cares receives it automatically. Zero coupling, zero leaks, zero hassle.
42
+
43
+ ---
44
+
45
+ **Technical summary:** DxMessaging is a high-performance, type-safe messaging system that replaces C# events, UnityEvents, and global event buses with a clean, observable, and predictable communication pattern.
46
+
47
+ **Think of it as:** The event system Unity should have shipped with.
48
+
49
+ ### What you get
50
+
51
+ - **Decoupled systems** - no manual subscribe/unsubscribe, impossible to leak
52
+ - **Predictable execution** - priority-based ordering, see exactly what runs when
53
+ - **Actually debuggable** - Inspector shows message history with timestamps
54
+ - **Scales effortlessly** - works for prototypes and 100k+ line codebases
37
55
 
38
56
  ## Quick Start
39
57
 
@@ -91,27 +109,76 @@ heal.EmitGameObjectTargeted(playerGameObject);
91
109
 
92
110
  ## Message Types
93
111
 
94
- - Untargeted: fire‑and‑forget announcements (no specific receiver)
95
- - Targeted: deliver to a specific receiver (GameObject, InstanceId, etc.)
96
- - Broadcast: deliver to all listeners (optionally including source metadata)
112
+ ### New to messaging? Use this decision tree
113
+
114
+ ```text
115
+ Is it a global announcement? (pause, settings, scene load)
116
+ → Use UNTARGETED
117
+
118
+ Are you commanding a specific entity? (heal Player, open Chest #3)
119
+ → Use TARGETED
120
+
121
+ Is an entity announcing something happened? (Enemy died, Chest opened)
122
+ → Use BROADCAST
123
+ ```
124
+
125
+ #### Examples
126
+
127
+ ```csharp
128
+ // Untargeted: "Everyone, the game paused!"
129
+ [DxUntargetedMessage]
130
+ public struct GamePaused { }
131
+
132
+ // Targeted: "Player, heal yourself by 50!"
133
+ [DxTargetedMessage]
134
+ public struct Heal { public int amount; }
97
135
 
98
- See [MessageTypes](MessageTypes.md) for details and APIs.
136
+ // Broadcast: "I (Enemy #3) just died!"
137
+ [DxBroadcastMessage]
138
+ public struct EnemyDied { public string enemyName; }
139
+ ```
140
+
141
+ **Still confused?** See the [Visual Guide](VisualGuide.md) for beginner-friendly explanations, or [MessageTypes](MessageTypes.md) for technical details.
99
142
 
100
143
  ## Common Patterns
101
144
 
102
- - UI reacting to gameplay state via targeted messages
103
- - Cross‑system notifications using broadcast messages
104
- - Configuration changes/feature toggles via untargeted announcements
145
+ ### Want to see real examples? Here's what DxMessaging excels at
146
+
147
+ - **UI reacting to gameplay** - Health bar updates when player takes damage (without UI knowing about Player)
148
+ - **Achievement systems** - Track ALL kills across ALL enemies with ONE listener
149
+ - **Cross-system coordination** - Scene transitions coordinate audio, save system, and UI automatically
150
+ - **Input handling** - Decouple input system from player controller
151
+ - **Analytics** - Track all events without polluting gameplay code
105
152
 
106
- See [ListeningPatterns](ListeningPatterns.md) and [Patterns](Patterns.md) for deeper examples.
153
+ **Want code examples?** See [Patterns](Patterns.md) for production-ready patterns and [ListeningPatterns](ListeningPatterns.md) for advanced techniques.
107
154
 
108
155
  ## Troubleshooting
109
156
 
110
- - Nothing happens? Ensure your listener registered in `RegisterMessageHandlers` and the component is enabled.
111
- - Duplicate behavior? Check for multiple registrations or missing token disposal on custom lifecycles.
112
- - Ordering issues? Use interceptors/post‑processors to control/inspect flow.
157
+ ### "My handler isn't being called!"
158
+
159
+ Checklist:
160
+
161
+ 1. Did you call `base.RegisterMessageHandlers()` first?
162
+ 1. Is your component enabled in the scene?
163
+ 1. Are you emitting to the right target? (Check GameObject vs Component)
164
+ 1. Check the Inspector - does the registration show up?
165
+
166
+ #### "My message is firing twice!"
167
+
168
+ - Check if you accidentally registered the same handler multiple times
169
+ - Make sure you're calling `base.RegisterMessageHandlers()` only once
170
+
171
+ ##### "I get a compile error on `[DxAutoConstructor]`"
172
+
173
+ - Did you mark the struct as `partial`? (required for code generation)
174
+ - Example: `public readonly partial struct MyMessage`
175
+
176
+ ###### "Which message type should I use?"
177
+
178
+ - See the decision tree in [Message Types](#message-types) above
179
+ - When in doubt, start with `Broadcast` - it's the most flexible
113
180
 
114
- See [Troubleshooting](Troubleshooting.md) for more.
181
+ **Still stuck?** See [Troubleshooting](Troubleshooting.md) for the complete guide or [FAQ](FAQ.md) for common questions.
115
182
 
116
183
  ## Next Steps
117
184
 
package/Docs/Helpers.md CHANGED
@@ -355,7 +355,7 @@ using DxMessaging.Core.MessageBus;
355
355
 
356
356
  // Create isolated bus
357
357
  var testBus = new MessageBus();
358
- var handler = new MessageHandler(new InstanceId(1)) { active = true };
358
+ var handler = new MessageHandler(new InstanceId(1), testBus) { active = true };
359
359
  var token = MessageRegistrationToken.Create(handler, testBus);
360
360
 
361
361
  // Register on isolated bus
package/Docs/Index.md CHANGED
@@ -4,28 +4,18 @@
4
4
 
5
5
  ## Visual Documentation Map
6
6
 
7
- ```text
8
- ┌─────────────────┐
9
- START HERE
10
- │ Visual Guide │
11
- │ (5 minutes) │
12
- └────────┬────────┘
13
-
14
- ┌──────────────────┼──────────────────┐
15
- │ │ │
16
- ┌─────▼──────┐ ┌─────▼──────┐ ┌─────▼──────┐
17
- │ Quick │ │ Getting │ │ Overview │
18
- │ Start │ │ Started │ │ │
19
- │ (5 min) │ │ (10 min) │ │ (5 min) │
20
- └─────┬──────┘ └─────┬──────┘ └─────┬──────┘
21
- │ │ │
22
- └──────────────────┼──────────────────┘
23
-
24
- ┌──────▼──────┐
25
- │ Patterns │
26
- │ & Samples │
27
- │ (Hands-on!) │
28
- └─────────────┘
7
+ ```mermaid
8
+ graph TD
9
+ Start[START HERE<br/>Visual Guide<br/>5 minutes]
10
+ Start --> Quick[Quick Start<br/>5 min]
11
+ Start --> Getting[Getting Started<br/>10 min]
12
+ Start --> Overview[Overview<br/>5 min]
13
+ Quick --> Patterns[Patterns & Samples<br/>Hands-on!]
14
+ Getting --> Patterns
15
+ Overview --> Patterns
16
+
17
+ style Start fill:#91d5ff,stroke:#096dd9,stroke-width:3px,color:#000
18
+ style Patterns fill:#95de64,stroke:#237804,stroke-width:2px,color:#000
29
19
  ```
30
20
 
31
21
  ## Table of Contents
@@ -108,6 +98,8 @@
108
98
  ### Tools & Utilities
109
99
 
110
100
  - **[Helpers](Helpers.md)** — Source generators, attributes, extensions
101
+ - **[Message Bus Providers](MessageBusProviders.md)** — Provider system and MessageBusProviderHandle for flexible bus configuration
102
+ - **[Runtime Configuration](RuntimeConfiguration.md)** — Setting message buses at runtime, re-binding registrations
111
103
  - **[Emit Shorthands](EmitShorthands.md)** — `Emit`/`EmitAt`/`EmitFrom` usage and pitfalls
112
104
  - **[String Messages](StringMessages.md)** — Prototyping and debugging
113
105
  - **[Compatibility](Compatibility.md)** — Unity versions and render pipelines
@@ -159,6 +151,9 @@ From [Common Patterns](Patterns.md):
159
151
  - **Debug message flow** → Use [Diagnostics](Diagnostics.md)
160
152
  - **Optimize performance** → Read [Performance Tips](DesignAndArchitecture.md#performance-tuning-tips)
161
153
  - **Isolate tests** → Create [Local Bus Islands](DesignAndArchitecture.md#local-bus-islands)
154
+ - **Use dependency injection** → [DxMessaging + Zenject](Integrations/Zenject.md), [DxMessaging + VContainer](Integrations/VContainer.md), [DxMessaging + Reflex](Integrations/Reflex.md)
155
+ - **Configure buses at runtime** → See [Runtime Configuration](RuntimeConfiguration.md)
156
+ - **Use message bus providers** → Learn [Message Bus Providers](MessageBusProviders.md)
162
157
 
163
158
  ## 📊 Visual: Message Pipeline
164
159
 
@@ -169,9 +164,9 @@ flowchart LR
169
164
  P[Producer] --> I[Interceptors<br/>validate/mutate/cancel]
170
165
  I --> H[Handlers<br/>main logic by priority]
171
166
  H --> PP[Post-Processors<br/>analytics/logging]
172
- style I fill:#fff4e5,stroke:#f0b429
173
- style H fill:#e6f7ff,stroke:#1890ff
174
- style PP fill:#eef7ee,stroke:#52c41a
167
+ style I fill:#ffe7ba,stroke:#d48806,stroke-width:2px,color:#000
168
+ style H fill:#91d5ff,stroke:#096dd9,stroke-width:2px,color:#000
169
+ style PP fill:#b7eb8f,stroke:#389e0d,stroke-width:2px,color:#000
175
170
  ```
176
171
 
177
172
  ## 🎓 Learning Resources
@@ -269,6 +264,14 @@ From [Comparisons](Comparisons.md):
269
264
  - [FAQ](FAQ.md)
270
265
  - [Troubleshooting](Troubleshooting.md)
271
266
 
267
+ ### Dependency Injection
268
+
269
+ - [Runtime Configuration](RuntimeConfiguration.md) — Setting and overriding message buses, re-binding registrations
270
+ - [Message Bus Providers](MessageBusProviders.md) — Provider system and MessageBusProviderHandle
271
+ - [DxMessaging + Zenject](Integrations/Zenject.md) — Zenject integration guide
272
+ - [DxMessaging + VContainer](Integrations/VContainer.md) — VContainer integration guide
273
+ - [DxMessaging + Reflex](Integrations/Reflex.md) — Reflex integration guide
274
+
272
275
  ### Miscellaneous
273
276
 
274
277
  - [String Messages](StringMessages.md)
package/Docs/Install.md CHANGED
@@ -2,34 +2,57 @@
2
2
 
3
3
  This page helps you install DxMessaging into a Unity 2021.3+ project using the Unity Package Manager (UPM).
4
4
 
5
- Fast path
5
+ ## Methods
6
+
7
+ ### Fast path
6
8
 
7
9
  - Unity Package Manager > Add package from git URL...
8
10
  - Paste:
9
11
 
10
12
  ```text
11
- https://github.com/wallstop/DxMessaging.git?path=/Packages/com.wallstop-studios.dxmessaging
13
+ https://github.com/wallstop/DxMessaging.git
12
14
  ```
13
15
 
14
16
  - Click Add. Unity imports the package and its analyzers/generators.
15
17
 
16
- Manifest.json (alternative)
18
+ ### To Install as Unity Package
19
+
20
+ 1. Open Unity Package Manager
21
+ 1. (Optional) Enable Pre-release packages to get the latest, cutting-edge builds
22
+ 1. Open the Advanced Package Settings
23
+ 1. Add an entry for a new "Scoped Registry"
24
+ - Name: `NPM`
25
+ - URL: `https://registry.npmjs.org`
26
+ - Scope(s): `com.wallstop-studios.dxmessaging`
27
+ 1. Resolve the latest `DxMessaging`
28
+
29
+ ⭐ Bonus of Unity Package way - Unity will tell you of version updates
30
+
31
+ ### From Releases
32
+
33
+ Check out the latest [Releases](https://github.com/wallstop/DxMessaging/releases) to grab the Unity Package and import to your project.
34
+
35
+ ### From Source
36
+
37
+ Grab a copy of this repo (either `git clone` [this repo](https://github.com/wallstop/DxMessaging) or [download a zip of the source](https://github.com/wallstop/DxMessaging/archive/refs/heads/master.zip)) and copy the contents to your project's `Assets` directory.
38
+
39
+ ### Manual - Manifest.json (alternative, not recommended)
17
40
 
18
41
  - Open your project’s `Packages/manifest.json` and add:
19
42
 
20
43
  ```json
21
44
  {
22
45
  "dependencies": {
23
- "com.wallstop-studios.dxmessaging": "https://github.com/wallstop/DxMessaging.git?path=/Packages/com.wallstop-studios.dxmessaging"
46
+ "com.wallstop-studios.dxmessaging": "https://github.com/wallstop/DxMessaging.git"
24
47
  }
25
48
  }
26
49
  ```
27
50
 
28
- Minimum requirements
51
+ ## Minimum requirements
29
52
 
30
53
  - Unity 2021.3+ (LTS recommended). See [Compatibility](Compatibility.md) for Unity × Render Pipeline support (Built‑In, URP, HDRP).
31
54
 
32
- After install
55
+ ## After install
33
56
 
34
57
  - In your project, create a GameObject and add `MessagingComponent` to start sending/receiving.
35
58
  - Optional: enable diagnostics in Editor from the MessagingComponent inspector to see live emissions.