com.wallstop-studios.dxmessaging 1.0.4 → 1.0.6

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/README.md CHANGED
@@ -11,10 +11,10 @@ Game engine agnostic robust, synchronous pub/sub C# messaging solution, mostly g
11
11
  4. Resolve the latest `DxMessaging`
12
12
 
13
13
  # Dependencies
14
- This project has a dependency on my [`Unity Helpers`](https://github.com/wallstop/unity-helpers) project, which contains the System.Runtime.CompilerServices.Unsafe.dll, which is used for some speed hacks in DxMessaging directly. Unity Helpers bundles a few (small) dependencies, including protobuf. If you don't want these dependencies, or if they conflict in some way, you can either include a copy of the System.Runtime.CompilerServices.Unsafe.dll yourself without relying on UnityHelpers, or manually download and include the Unity Helpers project and delete anything that conflicts with your project.
14
+ This project has a dependency on my [`Unity Helpers`](https://github.com/wallstop/unity-helpers) project, which contains the `System.Runtime.CompilerServices.Unsafe.dll`, which is used for some speed hacks in DxMessaging directly. Unity Helpers bundles a few (small) dependencies, including protobuf. If you don't want these dependencies, or if they conflict in some way, you can either include a copy of the `System.Runtime.CompilerServices.Unsafe.dll` yourself without relying on UnityHelpers, or manually download and include the Unity Helpers project and delete anything that conflicts with your project. Or, manually download this project without UnityHelpers. The choice is yours.
15
15
 
16
16
  # Benchmarks
17
- DxMessaging is currently a bit slower (2-4x) than Unity's built in messaging solution (when running in Unity). [Source](./Tests/Runtime/Core/PerformanceTests.cs).
17
+ DxMessaging is currently a bit slower (2-3x) than Unity's built in messaging solution (when running in Unity). [Source](./Tests/Runtime/Benchmarks/PerformanceTests.cs).
18
18
  | Message Tech | Operations / Second |
19
19
  | ------------ | ------------------- |
20
20
  | Unity | 1,908,539 |
@@ -4,12 +4,17 @@
4
4
  using System;
5
5
  using System.Collections.Generic;
6
6
  using UnityEngine;
7
-
7
+
8
8
  [DisallowMultipleComponent]
9
9
  public sealed class MessagingComponent : MonoBehaviour
10
10
  {
11
+ [SerializeField]
12
+ private bool _emitMessagesWhenDisabled;
13
+
11
14
  private MessageHandler _messageHandler;
12
- private readonly Dictionary<MonoBehaviour, MessageRegistrationToken> _registeredListeners = new Dictionary<MonoBehaviour, MessageRegistrationToken>();
15
+
16
+ private readonly Dictionary<MonoBehaviour, MessageRegistrationToken> _registeredListeners =
17
+ new Dictionary<MonoBehaviour, MessageRegistrationToken>();
13
18
 
14
19
  public MessageRegistrationToken Create(MonoBehaviour listener)
15
20
  {
@@ -20,9 +25,7 @@
20
25
 
21
26
  if (gameObject.GetInstanceID() != listener.gameObject.GetInstanceID())
22
27
  {
23
- throw new ArgumentException(string.Format(
24
- "Cannot create a RegistrationToken without an valid owner. {0}.",
25
- listener.gameObject.GetInstanceID()));
28
+ throw new ArgumentException($"Cannot create a RegistrationToken without an valid owner. {listener.gameObject.GetInstanceID()}.");
26
29
  }
27
30
 
28
31
  if (_registeredListeners.TryGetValue(listener, out MessageRegistrationToken createdToken))
@@ -37,14 +40,17 @@
37
40
  {
38
41
  active = true
39
42
  };
40
- MessagingDebug.Log(LogLevel.Debug, "Creating MessageHandler for componentType {0}, GameObject name: {1}, InstanceId: {2}.",
41
- listener.GetType(), listener.gameObject.name, (InstanceId) gameObject);
43
+ MessagingDebug.Log(
44
+ LogLevel.Debug,
45
+ "Creating MessageHandler for componentType {0}, GameObject name: {1}, InstanceId: {2}.",
46
+ listener.GetType(), listener.gameObject.name, (InstanceId)gameObject);
42
47
  }
43
48
  else
44
49
  {
45
- MessagingDebug.Log(LogLevel.Debug,
50
+ MessagingDebug.Log(
51
+ LogLevel.Debug,
46
52
  "Using existing MessageHandler for componentType {0}, GameObject name: {1}, InstanceId: {2}.",
47
- listener.GetType(), listener.gameObject.name, (InstanceId) gameObject);
53
+ listener.GetType(), listener.gameObject.name, (InstanceId)gameObject);
48
54
  }
49
55
 
50
56
  createdToken = MessageRegistrationToken.Create(_messageHandler);
@@ -64,10 +70,15 @@
64
70
 
65
71
  private void ToggleMessageHandler(bool newActive)
66
72
  {
73
+ if (!newActive && _emitMessagesWhenDisabled)
74
+ {
75
+ return;
76
+ }
77
+
67
78
  if (_messageHandler != null && _messageHandler.active != newActive)
68
79
  {
69
80
  _messageHandler.active = newActive;
70
81
  }
71
82
  }
72
83
  }
73
- }
84
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.dxmessaging",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "displayName": "DxMessaging",
5
5
  "description": "Synchronous Event Bus for Unity",
6
6
  "unity": "2021.1",
7
7
  "dependencies": {
8
- "com.wallstop-studios.unity-helpers" : "1.0.0-rc6"
8
+ "com.wallstop-studios.unity-helpers" : "1.0.1-rc13"
9
9
  },
10
10
  "keywords": [
11
11
  "messaging",
@@ -1,23 +0,0 @@
1
- {
2
- "name": "WallstopStudios.DxMessaging.Tests.Editor",
3
- "rootNamespace": "DxMessaging.Tests.Editor",
4
- "references": [
5
- "UnityEngine.TestRunner",
6
- "UnityEditor.TestRunner"
7
- ],
8
- "includePlatforms": [
9
- "Editor"
10
- ],
11
- "excludePlatforms": [],
12
- "allowUnsafeCode": false,
13
- "overrideReferences": true,
14
- "precompiledReferences": [
15
- "nunit.framework.dll"
16
- ],
17
- "autoReferenced": false,
18
- "defineConstraints": [
19
- "UNITY_INCLUDE_TESTS"
20
- ],
21
- "versionDefines": [],
22
- "noEngineReferences": false
23
- }
@@ -1,7 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: c646054334573af4a95dfd389817700c
3
- AssemblyDefinitionImporter:
4
- externalObjects: {}
5
- userData:
6
- assetBundleName:
7
- assetBundleVariant: