com.wallstop-studios.dxmessaging 2.1.2 → 2.1.4
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.
- package/.github/workflows/dotnet-tests.yml +3 -3
- package/.github/workflows/prettier-autofix.yml +0 -7
- package/.pre-commit-config.yaml +8 -5
- package/AGENTS.md +12 -12
- package/CONTRIBUTING.md +8 -2
- package/Docs/Comparisons.md +5 -5
- package/Docs/InterceptorsAndOrdering.md +1 -1
- package/Docs/Performance.md +13 -13
- package/Docs/QuickReference.md +1 -1
- package/Docs/Reference.md +5 -5
- package/Editor/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll +0 -0
- package/Editor/CustomEditors/MessagingComponentEditor.cs +3 -0
- package/Editor/DxMessagingEditorInitializer.cs +58 -1
- package/Editor/DxMessagingMenu.cs +38 -0
- package/Editor/DxMessagingMenu.cs.meta +11 -0
- package/Editor/DxMessagingSceneBuildProcessor.cs +81 -0
- package/Editor/DxMessagingSceneBuildProcessor.cs.meta +11 -0
- package/Editor/Settings/DxMessagingSettings.cs +37 -6
- package/Editor/Settings/DxMessagingSettingsProvider.cs +45 -7
- package/README.md +1 -1
- package/Runtime/Core/Attributes/DxOptionalParameterAttribute.cs +52 -0
- package/Runtime/Core/DataStructure/CyclicBuffer.cs +16 -0
- package/Runtime/Core/Diagnostics/MessageEmissionData.cs +1 -1
- package/Runtime/Core/Diagnostics/MessageRegistrationType.cs +62 -0
- package/Runtime/Core/DxMessagingStaticState.cs +108 -0
- package/Runtime/Core/DxMessagingStaticState.cs.meta +11 -0
- package/Runtime/Core/Extensions/IListExtensions.cs +24 -0
- package/Runtime/Core/Extensions/MessageBusExtensions.cs +142 -0
- package/Runtime/Core/Helper/MessageCache.cs +16 -0
- package/Runtime/Core/Helper/MessageHelperIndexer.cs +77 -0
- package/Runtime/Core/InstanceId.cs +86 -0
- package/Runtime/Core/MessageBus/DiagnosticsTarget.cs +31 -0
- package/Runtime/Core/MessageBus/DiagnosticsTarget.cs.meta +11 -0
- package/Runtime/Core/MessageBus/IMessageBus.cs +44 -16
- package/Runtime/Core/MessageBus/MessageBus.cs +167 -180
- package/Runtime/Core/MessageBus/MessageRegistrationBuilder.cs +44 -0
- package/Runtime/Core/MessageBus/MessagingRegistration.cs +60 -2
- package/Runtime/Core/MessageBus/RegistrationLog.cs +10 -0
- package/Runtime/Core/MessageHandler.cs +107 -6
- package/Runtime/Core/MessageRegistrationHandle.cs +59 -0
- package/Runtime/Core/MessageRegistrationToken.cs +18 -2
- package/Runtime/Core/Messages/ReflexiveMessage.cs +38 -0
- package/Runtime/Core/MessagingDebug.cs +16 -1
- package/Runtime/Unity/CurrentGlobalMessageBusProvider.cs +4 -0
- package/Runtime/Unity/DxMessagingRuntimeInitializer.cs +19 -0
- package/Runtime/Unity/DxMessagingRuntimeInitializer.cs.meta +11 -0
- package/Runtime/Unity/InitialGlobalMessageBusProvider.cs +4 -0
- package/Runtime/Unity/Integrations/Reflex/ReflexRegistrationInstaller.cs +17 -0
- package/Runtime/Unity/Integrations/VContainer/VContainerRegistrationExtensions.cs +8 -0
- package/Runtime/Unity/Integrations/Zenject/ZenjectRegistrationInstaller.cs +12 -0
- package/Runtime/Unity/MessagingComponent.cs +93 -0
- package/Samples~/DI/README.md +13 -13
- package/Samples~/Mini Combat/README.md +15 -15
- package/Samples~/Mini Combat/Walkthrough.md +12 -12
- package/Samples~/UI Buttons + Inspector/README.md +4 -4
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoConstructorGenerator.cs +4 -0
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxMessageIdGenerator.cs +4 -0
- package/Tests/Runtime/Core/DiagnosticsTests.cs +3 -3
- package/Tests/Runtime/Core/DxMessagingStaticStateTests.cs +69 -0
- package/Tests/Runtime/Core/DxMessagingStaticStateTests.cs.meta +11 -0
- package/Tests/Runtime/Core/Extensions/MessageBusExtensionsTests.cs +12 -31
- package/Tests/Runtime/Core/OrderingManyRegistrationsTests.cs +683 -0
- package/Tests/Runtime/Core/OrderingManyRegistrationsTests.cs.meta +11 -0
- package/package.json +1 -1
- package/scripts/fix-eol.js +38 -3
- package/Tests/Runtime/WallstopStudios.DxMessaging.Tests.Runtime.csproj +0 -20
- package/Tests/Runtime/WallstopStudios.DxMessaging.Tests.Runtime.csproj.meta +0 -7
|
@@ -16,10 +16,10 @@ jobs:
|
|
|
16
16
|
|
|
17
17
|
steps:
|
|
18
18
|
- name: Checkout
|
|
19
|
-
uses: actions/checkout@
|
|
19
|
+
uses: actions/checkout@v5
|
|
20
20
|
|
|
21
21
|
- name: Setup .NET
|
|
22
|
-
uses: actions/setup-dotnet@
|
|
22
|
+
uses: actions/setup-dotnet@v5
|
|
23
23
|
with:
|
|
24
24
|
dotnet-version: "9.0.x"
|
|
25
25
|
|
|
@@ -47,7 +47,7 @@ jobs:
|
|
|
47
47
|
cat artifacts/coverage/Summary.txt
|
|
48
48
|
|
|
49
49
|
- name: Upload coverage report
|
|
50
|
-
uses: actions/upload-artifact@
|
|
50
|
+
uses: actions/upload-artifact@v5
|
|
51
51
|
with:
|
|
52
52
|
name: generator-coverage
|
|
53
53
|
path: artifacts/coverage
|
|
@@ -46,10 +46,6 @@ jobs:
|
|
|
46
46
|
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
|
|
47
47
|
run: npx --yes markdownlint-cli@0.40.0 "**/*.md" "**/*.markdown" --config .markdownlint.json --ignore-path .markdownlintignore --fix
|
|
48
48
|
|
|
49
|
-
- name: Fix EOL/BOM (Dependabot only)
|
|
50
|
-
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
|
|
51
|
-
run: node scripts/fix-eol.js -v
|
|
52
|
-
|
|
53
49
|
- name: Commit formatting changes to PR branch (Dependabot only)
|
|
54
50
|
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.user.login == 'dependabot[bot]' }}
|
|
55
51
|
uses: stefanzweifel/git-auto-commit-action@v7
|
|
@@ -118,9 +114,6 @@ jobs:
|
|
|
118
114
|
- name: Markdownlint (auto-fix)
|
|
119
115
|
run: npx --yes markdownlint-cli@0.40.0 "**/*.md" "**/*.markdown" --config .markdownlint.json --ignore-path .markdownlintignore --fix
|
|
120
116
|
|
|
121
|
-
- name: Fix EOL/BOM
|
|
122
|
-
run: node scripts/fix-eol.js -v
|
|
123
|
-
|
|
124
117
|
- name: Detect changes
|
|
125
118
|
id: changes
|
|
126
119
|
shell: bash
|
package/.pre-commit-config.yaml
CHANGED
|
@@ -57,14 +57,17 @@ repos:
|
|
|
57
57
|
|
|
58
58
|
- repo: local
|
|
59
59
|
hooks:
|
|
60
|
-
- id: eol
|
|
61
|
-
name:
|
|
62
|
-
entry: node scripts/fix-eol.js
|
|
60
|
+
- id: fix-eol
|
|
61
|
+
name: Normalize CRLF and strip BOM
|
|
62
|
+
entry: node scripts/fix-eol.js
|
|
63
63
|
language: system
|
|
64
|
-
pass_filenames: false
|
|
65
64
|
stages:
|
|
66
65
|
- pre-commit
|
|
67
|
-
|
|
66
|
+
pass_filenames: true
|
|
67
|
+
description: Automatically rewrite text files to match CI EOL/BOM policy.
|
|
68
|
+
|
|
69
|
+
- repo: local
|
|
70
|
+
hooks:
|
|
68
71
|
- id: eol-bom-check
|
|
69
72
|
name: Enforce CRLF and no BOM
|
|
70
73
|
entry: node scripts/check-eol.js
|
package/AGENTS.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Project Structure & Module Organization
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
- Package manifest:
|
|
5
|
+
- [Runtime](Runtime/) — core library (`DxMessaging.Core`) and Unity components (`DxMessaging.Unity`).
|
|
6
|
+
- [Editor](Editor/) — editor utilities, analyzers, and setup (`DxMessaging.Editor`).
|
|
7
|
+
- [SourceGenerators](SourceGenerators/) — Roslyn source generators (`netstandard2.0`).
|
|
8
|
+
- [Tests/Runtime](Tests/Runtime/) — NUnit/Unity Test Framework tests (e.g., [Core Nominal tests](Tests/Runtime/Core/NominalTests.cs)).
|
|
9
|
+
- [Docs](Docs/) — usage patterns and examples.
|
|
10
|
+
- Package manifest: [package.json](package.json) (published to NPM/UPM).
|
|
11
11
|
|
|
12
12
|
## Build, Test, and Development Commands
|
|
13
13
|
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
|
|
18
18
|
## Coding Style & Naming Conventions
|
|
19
19
|
|
|
20
|
-
- Indent with 4 spaces for `.cs` (JSON/YAML: 2). CRLF, UTF‑8 BOM (see
|
|
20
|
+
- Indent with 4 spaces for `.cs` (JSON/YAML: 2). CRLF, UTF‑8 BOM (see [.editorconfig](.editorconfig)).
|
|
21
21
|
- Prefer explicit types over `var`. Braces required. `using` directives inside the namespace.
|
|
22
|
-
- Naming: `PascalCase` for types/methods/properties; interfaces `I*`; type parameters `T*`; events prefixed `On*`; public fields lowerCamelCase (matches examples in
|
|
22
|
+
- Naming: `PascalCase` for types/methods/properties; interfaces `I*`; type parameters `T*`; events prefixed `On*`; public fields lowerCamelCase (matches examples in the [README](README.md)).
|
|
23
23
|
- Place code under `DxMessaging.Core`, `DxMessaging.Unity`, or `DxMessaging.Editor` as appropriate.
|
|
24
24
|
- Do not use underscores in function names, especially test function names.
|
|
25
25
|
- Do not use regions, anywhere, ever.
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
## Testing Guidelines
|
|
30
30
|
|
|
31
31
|
- Frameworks: NUnit + Unity Test Framework. Use `[Test]`/`[UnityTest]` as needed.
|
|
32
|
-
- Location: add files under
|
|
32
|
+
- Location: add files under [Tests/Runtime](Tests/Runtime/) `<Area>/` named `*Tests.cs` with classes `*Tests`.
|
|
33
33
|
- Keep tests independent: prefer a local `MessageBus` and explicit `MessageRegistrationToken` lifecycles.
|
|
34
34
|
- Do not use underscores in test function names.
|
|
35
35
|
- Prefer expressive assertions and failure messages so it is clear what exactly is failing when a test fails.
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
## Commit & Pull Request Guidelines
|
|
44
44
|
|
|
45
45
|
- Commits: short, imperative subject; group related changes; reference issues/PRs (e.g., “Fix registration dedupe (#123)”).
|
|
46
|
-
- PRs: include a clear description, linked issues, before/after notes for performance changes (see
|
|
47
|
-
- Releasing: changes to
|
|
46
|
+
- PRs: include a clear description, linked issues, before/after notes for performance changes (see [Tests/Runtime/Benchmarks](Tests/Runtime/Benchmarks/)), and tests for bug fixes/features.
|
|
47
|
+
- Releasing: changes to [package.json](package.json) on `master` may trigger the NPM publish workflow.
|
|
48
48
|
|
|
49
49
|
## Security & Configuration Tips
|
|
50
50
|
|
|
51
|
-
- Editor analyzer DLLs are copied into the Unity project by
|
|
51
|
+
- Editor analyzer DLLs are copied into the Unity project by [SetupCscRsp.cs](Editor/SetupCscRsp.cs); do not commit generated DLLs into this repo.
|
|
52
52
|
- Keep public APIs minimal and consistent; avoid breaking changes without a major version bump.
|
package/CONTRIBUTING.md
CHANGED
|
@@ -8,7 +8,12 @@ Before committing, please enable our git hooks and local linters so you catch is
|
|
|
8
8
|
- Install hooks: `pre-commit install`
|
|
9
9
|
- Run on all files: `pre-commit run --all-files`
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Line endings: Git already normalizes files to CRLF through `.gitattributes`. Run this once after cloning (especially on Windows) so your working tree matches CI:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
git config core.autocrlf false
|
|
15
|
+
git add --renormalize .
|
|
16
|
+
```
|
|
12
17
|
|
|
13
18
|
What runs locally:
|
|
14
19
|
|
|
@@ -29,5 +34,6 @@ Handy commands:
|
|
|
29
34
|
- Format JSON/.asmdef (manual): `npx prettier@3.6.2 --write "**/*.{json,asmdef}"`
|
|
30
35
|
- Format YAML (all files): `pre-commit run prettier-yaml --all-files`
|
|
31
36
|
- Check YAML formatting + lint: `npm run check:yaml`
|
|
32
|
-
- Fix EOL/BOM issues quickly: `node scripts/fix-eol.js -v`
|
|
33
37
|
- Format C#: `dotnet tool restore && dotnet tool run csharpier format`
|
|
38
|
+
|
|
39
|
+
If you do still need to repair line endings manually (for example, after copying files from an external tool), run `node scripts/fix-eol.js -v` and then re-stage the affected files.
|
package/Docs/Comparisons.md
CHANGED
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
|
|
29
29
|
## Performance Benchmarks
|
|
30
30
|
|
|
31
|
-
These sections are auto-updated by the PlayMode comparison benchmarks in
|
|
31
|
+
These sections are auto-updated by the PlayMode comparison benchmarks in the [Comparison Performance PlayMode tests](../Tests/Runtime/Benchmarks/ComparisonPerformanceTests.cs). Run the suite locally to refresh the tables.
|
|
32
32
|
|
|
33
33
|
### Comparisons (Windows)
|
|
34
34
|
|
|
35
35
|
| Message Tech | Operations / Second | Allocations? |
|
|
36
36
|
| ---------------------------------- | ------------------- | ------------ |
|
|
37
|
-
| DxMessaging (Untargeted) - No-Copy | 14,
|
|
38
|
-
| UniRx MessageBroker | 18,
|
|
39
|
-
| MessagePipe (Global) | 97,
|
|
40
|
-
| Zenject SignalBus | 2,
|
|
37
|
+
| DxMessaging (Untargeted) - No-Copy | 14,640,000 | No |
|
|
38
|
+
| UniRx MessageBroker | 18,074,000 | No |
|
|
39
|
+
| MessagePipe (Global) | 97,824,000 | No |
|
|
40
|
+
| Zenject SignalBus | 2,354,000 | Yes |
|
|
41
41
|
|
|
42
42
|
### Comparisons (macOS)
|
|
43
43
|
|
|
@@ -36,7 +36,7 @@ new GameEvent().Emit(); // Both DoWork() and ProcessLater() execute
|
|
|
36
36
|
- Ensures all listeners see a consistent view of the registration state
|
|
37
37
|
- Makes debugging and reasoning about message flow easier
|
|
38
38
|
|
|
39
|
-
This snapshot behavior is extensively tested in
|
|
39
|
+
This snapshot behavior is extensively tested in the [Mutation During Emission tests](../Tests/Runtime/Core/MutationDuringEmissionTests.cs).
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
package/Docs/Performance.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Performance Benchmarks
|
|
2
2
|
|
|
3
|
-
This page is auto-updated by the Unity PlayMode benchmark tests in
|
|
3
|
+
This page is auto-updated by the Unity PlayMode benchmark tests in the [Performance PlayMode benchmark suite](../Tests/Runtime/Benchmarks/PerformanceTests.cs).
|
|
4
4
|
|
|
5
5
|
How it works:
|
|
6
6
|
|
|
@@ -8,23 +8,23 @@ How it works:
|
|
|
8
8
|
- The benchmark test writes an OS-specific section below with a markdown table.
|
|
9
9
|
- CI runs skip writing to avoid noisy diffs.
|
|
10
10
|
|
|
11
|
-
See also:
|
|
11
|
+
See also: [Performance optimizations](./DesignAndArchitecture.md#performance-optimizations) for design details.
|
|
12
12
|
|
|
13
13
|
## Windows
|
|
14
14
|
|
|
15
15
|
| Message Tech | Operations / Second | Allocations? |
|
|
16
16
|
| ------------------------------------------ | ------------------- | ------------ |
|
|
17
|
-
| Unity | 2,
|
|
18
|
-
| DxMessaging (GameObject) - Normal | 8,
|
|
19
|
-
| DxMessaging (Component) - Normal | 8,
|
|
20
|
-
| DxMessaging (GameObject) - No-Copy | 9,
|
|
21
|
-
| DxMessaging (Component) - No-Copy | 9,
|
|
22
|
-
| DxMessaging (Untargeted) - No-Copy |
|
|
23
|
-
| DxMessaging (Untargeted) - Interceptors | 6,
|
|
24
|
-
| DxMessaging (Untargeted) - Post-Processors | 5,
|
|
25
|
-
| Reflexive (One Argument) | 2,
|
|
26
|
-
| Reflexive (Two Arguments) | 2,
|
|
27
|
-
| Reflexive (Three Arguments) | 2,
|
|
17
|
+
| Unity | 2,522,000 | Yes |
|
|
18
|
+
| DxMessaging (GameObject) - Normal | 8,606,000 | No |
|
|
19
|
+
| DxMessaging (Component) - Normal | 8,608,000 | No |
|
|
20
|
+
| DxMessaging (GameObject) - No-Copy | 9,534,000 | No |
|
|
21
|
+
| DxMessaging (Component) - No-Copy | 9,658,000 | No |
|
|
22
|
+
| DxMessaging (Untargeted) - No-Copy | 15,008,000 | No |
|
|
23
|
+
| DxMessaging (Untargeted) - Interceptors | 6,944,000 | No |
|
|
24
|
+
| DxMessaging (Untargeted) - Post-Processors | 5,146,000 | No |
|
|
25
|
+
| Reflexive (One Argument) | 2,822,000 | No |
|
|
26
|
+
| Reflexive (Two Arguments) | 2,370,000 | No |
|
|
27
|
+
| Reflexive (Three Arguments) | 2,342,000 | No |
|
|
28
28
|
|
|
29
29
|
## macOS
|
|
30
30
|
|
package/Docs/QuickReference.md
CHANGED
|
@@ -106,7 +106,7 @@ public sealed class DamageSystem : IStartable, IDisposable
|
|
|
106
106
|
}
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
Tip: Define `ZENJECT_PRESENT`, `VCONTAINER_PRESENT`, or `REFLEX_PRESENT` to enable the optional shims under
|
|
109
|
+
Tip: Define `ZENJECT_PRESENT`, `VCONTAINER_PRESENT`, or `REFLEX_PRESENT` to enable the optional shims under [Runtime/Unity/Integrations](../Runtime/Unity/Integrations/) that bind the builder automatically for those containers.
|
|
110
110
|
|
|
111
111
|
Interceptors and post‑processors
|
|
112
112
|
|
package/Docs/Reference.md
CHANGED
|
@@ -64,11 +64,11 @@ Unity bridge types
|
|
|
64
64
|
|
|
65
65
|
Source files (for exploration)
|
|
66
66
|
|
|
67
|
-
- Message bus interface: Runtime/Core/MessageBus/IMessageBus.cs
|
|
68
|
-
- Message bus: Runtime/Core/MessageBus/MessageBus.cs
|
|
69
|
-
- Message handler/token: Runtime/Core/MessageHandler.cs, Runtime/Core/MessageRegistrationToken.cs
|
|
70
|
-
- Emit helpers: Runtime/Core/Extensions/MessageExtensions.cs
|
|
71
|
-
- Attributes: Runtime/Core/Attributes
|
|
67
|
+
- Message bus interface: [IMessageBus](../Runtime/Core/MessageBus/IMessageBus.cs)
|
|
68
|
+
- Message bus: [MessageBus](../Runtime/Core/MessageBus/MessageBus.cs)
|
|
69
|
+
- Message handler/token: [MessageHandler](../Runtime/Core/MessageHandler.cs), [MessageRegistrationToken](../Runtime/Core/MessageRegistrationToken.cs)
|
|
70
|
+
- Emit helpers: [MessageExtensions](../Runtime/Core/Extensions/MessageExtensions.cs)
|
|
71
|
+
- Attributes: [Attributes directory](../Runtime/Core/Attributes/)
|
|
72
72
|
|
|
73
73
|
API tables (quick view)
|
|
74
74
|
|
|
Binary file
|
|
@@ -37,6 +37,9 @@ namespace DxMessaging.Editor.CustomEditors
|
|
|
37
37
|
_listenerFoldouts.Clear();
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/// <summary>
|
|
41
|
+
/// Draws the custom inspector, including diagnostics summaries and listener management controls.
|
|
42
|
+
/// </summary>
|
|
40
43
|
public override void OnInspectorGUI()
|
|
41
44
|
{
|
|
42
45
|
base.OnInspectorGUI();
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
namespace DxMessaging.Editor
|
|
2
2
|
{
|
|
3
3
|
#if UNITY_EDITOR
|
|
4
|
+
using Core;
|
|
4
5
|
using Core.MessageBus;
|
|
5
6
|
using Settings;
|
|
6
7
|
using UnityEditor;
|
|
8
|
+
using UnityEngine;
|
|
7
9
|
|
|
8
10
|
/// <summary>
|
|
9
11
|
/// Applies DxMessaging Editor settings to global runtime defaults on domain load.
|
|
@@ -11,12 +13,67 @@ namespace DxMessaging.Editor
|
|
|
11
13
|
[InitializeOnLoad]
|
|
12
14
|
public static class DxMessagingEditorInitializer
|
|
13
15
|
{
|
|
16
|
+
private static bool s_playModeWarningIssued;
|
|
17
|
+
|
|
14
18
|
static DxMessagingEditorInitializer()
|
|
15
19
|
{
|
|
20
|
+
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
|
21
|
+
ApplyEditorSettings();
|
|
22
|
+
WarnIfDomainReloadDisabled();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private static void OnPlayModeStateChanged(PlayModeStateChange stateChange)
|
|
26
|
+
{
|
|
27
|
+
if (
|
|
28
|
+
stateChange == PlayModeStateChange.EnteredEditMode
|
|
29
|
+
|| stateChange == PlayModeStateChange.EnteredPlayMode
|
|
30
|
+
)
|
|
31
|
+
{
|
|
32
|
+
ApplyEditorSettings();
|
|
33
|
+
WarnIfDomainReloadDisabled();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
|
38
|
+
private static void ApplySettingsBeforeSceneLoad()
|
|
39
|
+
{
|
|
40
|
+
if (!Application.isPlaying)
|
|
41
|
+
{
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
ApplyEditorSettings();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private static void ApplyEditorSettings()
|
|
49
|
+
{
|
|
50
|
+
DxMessagingStaticState.Reset();
|
|
16
51
|
DxMessagingSettings settings = DxMessagingSettings.GetOrCreateSettings();
|
|
17
|
-
IMessageBus.
|
|
52
|
+
IMessageBus.GlobalDiagnosticsTargets = settings.DiagnosticsTargets;
|
|
18
53
|
IMessageBus.GlobalMessageBufferSize = settings.MessageBufferSize;
|
|
19
54
|
}
|
|
55
|
+
|
|
56
|
+
private static void WarnIfDomainReloadDisabled()
|
|
57
|
+
{
|
|
58
|
+
DxMessagingSettings settings = DxMessagingSettings.GetOrCreateSettings();
|
|
59
|
+
if (
|
|
60
|
+
s_playModeWarningIssued
|
|
61
|
+
|| settings.SuppressDomainReloadWarning
|
|
62
|
+
|| !EditorSettings.enterPlayModeOptionsEnabled
|
|
63
|
+
|| (EditorSettings.enterPlayModeOptions & EnterPlayModeOptions.DisableDomainReload)
|
|
64
|
+
== 0
|
|
65
|
+
)
|
|
66
|
+
{
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
s_playModeWarningIssued = true;
|
|
71
|
+
Debug.LogWarning(
|
|
72
|
+
"[DxMessaging] Enter Play Mode Options are disabling domain reload. "
|
|
73
|
+
+ "DxMessaging resets its internal statics, but third-party static state will persist. "
|
|
74
|
+
+ "Audit integration code or re-enable domain reload if inconsistent behaviour occurs."
|
|
75
|
+
);
|
|
76
|
+
}
|
|
20
77
|
}
|
|
21
78
|
#endif
|
|
22
79
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
namespace DxMessaging.Editor
|
|
2
|
+
{
|
|
3
|
+
#if UNITY_EDITOR
|
|
4
|
+
using Core;
|
|
5
|
+
using Core.MessageBus;
|
|
6
|
+
using UnityEditor;
|
|
7
|
+
using UnityEngine;
|
|
8
|
+
|
|
9
|
+
internal static class DxMessagingMenu
|
|
10
|
+
{
|
|
11
|
+
private const string Root = "Tools/Wallstop Studios/DxMessaging/";
|
|
12
|
+
|
|
13
|
+
[MenuItem(Root + "Reset Static State")]
|
|
14
|
+
private static void ResetStatics()
|
|
15
|
+
{
|
|
16
|
+
DxMessagingStaticState.Reset();
|
|
17
|
+
Debug.Log("[DxMessaging] Static state reset.");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[MenuItem(Root + "Toggle Global Diagnostics")]
|
|
21
|
+
private static void ToggleGlobalDiagnostics()
|
|
22
|
+
{
|
|
23
|
+
DiagnosticsTarget current = IMessageBus.GlobalDiagnosticsTargets;
|
|
24
|
+
DiagnosticsTarget next = current switch
|
|
25
|
+
{
|
|
26
|
+
DiagnosticsTarget.Off => DiagnosticsTarget.Editor,
|
|
27
|
+
DiagnosticsTarget.Editor => DiagnosticsTarget.Runtime,
|
|
28
|
+
DiagnosticsTarget.Runtime => DiagnosticsTarget.All,
|
|
29
|
+
DiagnosticsTarget.All => DiagnosticsTarget.Off,
|
|
30
|
+
_ => DiagnosticsTarget.Off,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
IMessageBus.GlobalDiagnosticsTargets = next;
|
|
34
|
+
Debug.Log($"[DxMessaging] Global diagnostics targets set to {next}.");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
#endif
|
|
38
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
namespace DxMessaging.Editor
|
|
2
|
+
{
|
|
3
|
+
#if UNITY_EDITOR && UNITY_2021_3_OR_NEWER
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using DxMessaging.Unity;
|
|
6
|
+
using UnityEditor.Build;
|
|
7
|
+
using UnityEditor.Build.Reporting;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
using UnityEngine.SceneManagement;
|
|
10
|
+
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// Ensures MessagingComponent instances do not carry runtime registrations into player builds.
|
|
13
|
+
/// </summary>
|
|
14
|
+
internal sealed class DxMessagingSceneBuildProcessor : IProcessSceneWithReport
|
|
15
|
+
{
|
|
16
|
+
public int callbackOrder => int.MaxValue;
|
|
17
|
+
|
|
18
|
+
/// <summary>
|
|
19
|
+
/// Strips runtime-only messaging state from the scene before it is serialized into the build.
|
|
20
|
+
/// </summary>
|
|
21
|
+
/// <param name="scene">Scene currently being processed.</param>
|
|
22
|
+
/// <param name="report">Build report associated with the scene export.</param>
|
|
23
|
+
public void OnProcessScene(Scene scene, BuildReport report)
|
|
24
|
+
{
|
|
25
|
+
if (!scene.IsValid() || !scene.isLoaded)
|
|
26
|
+
{
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
MessagingComponent[] components = FindMessagingComponents(scene);
|
|
31
|
+
if (components == null || components.Length == 0)
|
|
32
|
+
{
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
int cleared = 0;
|
|
37
|
+
for (int i = 0; i < components.Length; ++i)
|
|
38
|
+
{
|
|
39
|
+
MessagingComponent component = components[i];
|
|
40
|
+
if (component != null && component.EditorResetRuntimeState())
|
|
41
|
+
{
|
|
42
|
+
cleared++;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (cleared > 0 && report != null)
|
|
47
|
+
{
|
|
48
|
+
Debug.Log(
|
|
49
|
+
$"[DxMessaging] Cleared {cleared} MessagingComponent instance(s) in scene '{scene.path}' prior to build."
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private static MessagingComponent[] FindMessagingComponents(Scene scene)
|
|
55
|
+
{
|
|
56
|
+
List<MessagingComponent> buffer = new List<MessagingComponent>();
|
|
57
|
+
GameObject[] roots = scene.GetRootGameObjects();
|
|
58
|
+
for (int i = 0; i < roots.Length; ++i)
|
|
59
|
+
{
|
|
60
|
+
GameObject root = roots[i];
|
|
61
|
+
if (root == null)
|
|
62
|
+
{
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
MessagingComponent[] components = root.GetComponentsInChildren<MessagingComponent>(
|
|
67
|
+
includeInactive: true
|
|
68
|
+
);
|
|
69
|
+
if (components == null || components.Length == 0)
|
|
70
|
+
{
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
buffer.AddRange(components);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return buffer.ToArray();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
#endif
|
|
81
|
+
}
|
|
@@ -2,8 +2,10 @@ namespace DxMessaging.Editor.Settings
|
|
|
2
2
|
{
|
|
3
3
|
#if UNITY_EDITOR
|
|
4
4
|
using System.Linq;
|
|
5
|
+
using Core.MessageBus;
|
|
5
6
|
using UnityEditor;
|
|
6
7
|
using UnityEngine;
|
|
8
|
+
using UnityEngine.Serialization;
|
|
7
9
|
|
|
8
10
|
/// <summary>
|
|
9
11
|
/// Project-wide DxMessaging settings asset (Editor-only).
|
|
@@ -18,18 +20,26 @@ namespace DxMessaging.Editor.Settings
|
|
|
18
20
|
private const string SettingsPath = "Assets/Editor/DxMessagingSettings.asset";
|
|
19
21
|
|
|
20
22
|
[SerializeField]
|
|
21
|
-
internal
|
|
23
|
+
internal DiagnosticsTarget _diagnosticsTargets = DiagnosticsTarget.Off;
|
|
24
|
+
|
|
25
|
+
[SerializeField]
|
|
26
|
+
[HideInInspector]
|
|
27
|
+
[FormerlySerializedAs("_enableDiagnosticsInEditor")]
|
|
28
|
+
private bool _legacyEnableDiagnosticsInEditor;
|
|
22
29
|
|
|
23
30
|
[SerializeField]
|
|
24
31
|
internal int _messageBufferSize = DefaultBufferSize;
|
|
25
32
|
|
|
33
|
+
[SerializeField]
|
|
34
|
+
internal bool _suppressDomainReloadWarning = true;
|
|
35
|
+
|
|
26
36
|
/// <summary>
|
|
27
|
-
///
|
|
37
|
+
/// Controls <see cref="DiagnosticsTarget"/> values applied to <see cref="IMessageBus.GlobalDiagnosticsTargets"/>.
|
|
28
38
|
/// </summary>
|
|
29
|
-
public
|
|
39
|
+
public DiagnosticsTarget DiagnosticsTargets
|
|
30
40
|
{
|
|
31
|
-
get =>
|
|
32
|
-
set =>
|
|
41
|
+
get => _diagnosticsTargets;
|
|
42
|
+
set => _diagnosticsTargets = value;
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
/// <summary>
|
|
@@ -41,6 +51,15 @@ namespace DxMessaging.Editor.Settings
|
|
|
41
51
|
set => _messageBufferSize = value;
|
|
42
52
|
}
|
|
43
53
|
|
|
54
|
+
/// <summary>
|
|
55
|
+
/// When true, suppresses the Enter Play Mode Options domain reload warning in the Editor.
|
|
56
|
+
/// </summary>
|
|
57
|
+
public bool SuppressDomainReloadWarning
|
|
58
|
+
{
|
|
59
|
+
get => _suppressDomainReloadWarning;
|
|
60
|
+
set => _suppressDomainReloadWarning = value;
|
|
61
|
+
}
|
|
62
|
+
|
|
44
63
|
/// <summary>
|
|
45
64
|
/// Loads the settings asset if present, otherwise creates it with sensible defaults.
|
|
46
65
|
/// </summary>
|
|
@@ -62,8 +81,9 @@ namespace DxMessaging.Editor.Settings
|
|
|
62
81
|
if (settings == null)
|
|
63
82
|
{
|
|
64
83
|
settings = CreateInstance<DxMessagingSettings>();
|
|
65
|
-
settings.
|
|
84
|
+
settings._diagnosticsTargets = DiagnosticsTarget.Off;
|
|
66
85
|
settings._messageBufferSize = DefaultBufferSize;
|
|
86
|
+
settings._suppressDomainReloadWarning = true;
|
|
67
87
|
if (!AssetDatabase.IsValidFolder("Assets/Editor"))
|
|
68
88
|
{
|
|
69
89
|
AssetDatabase.CreateFolder("Assets", "Editor");
|
|
@@ -72,6 +92,17 @@ namespace DxMessaging.Editor.Settings
|
|
|
72
92
|
AssetDatabase.SaveAssets();
|
|
73
93
|
}
|
|
74
94
|
|
|
95
|
+
if (
|
|
96
|
+
settings._diagnosticsTargets == DiagnosticsTarget.Off
|
|
97
|
+
&& settings._legacyEnableDiagnosticsInEditor
|
|
98
|
+
)
|
|
99
|
+
{
|
|
100
|
+
settings._diagnosticsTargets = DiagnosticsTarget.Editor;
|
|
101
|
+
settings._legacyEnableDiagnosticsInEditor = false;
|
|
102
|
+
EditorUtility.SetDirty(settings);
|
|
103
|
+
AssetDatabase.SaveAssets();
|
|
104
|
+
}
|
|
105
|
+
|
|
75
106
|
return settings;
|
|
76
107
|
}
|
|
77
108
|
|