com.wallstop-studios.dxmessaging 1.0.5 → 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/Runtime/Unity/MessagingComponent.cs +21 -10
- package/Tests/Runtime/WallstopStudios.DxMessaging.Tests.Runtime.asmdef +21 -23
- package/package.json +2 -2
- package/Tests/Editor/WallstopStudios.DxMessaging.Tests.Editor.asmdef +0 -23
- package/Tests/Editor/WallstopStudios.DxMessaging.Tests.Editor.asmdef.meta +0 -7
|
@@ -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
|
-
|
|
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(
|
|
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(
|
|
41
|
-
|
|
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(
|
|
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)
|
|
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
|
+
}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "WallstopStudios.DxMessaging.Tests.Runtime",
|
|
3
|
-
"rootNamespace": "DxMessaging.Tests",
|
|
4
|
-
"references": [
|
|
5
|
-
"UnityEngine.TestRunner",
|
|
6
|
-
"UnityEditor.TestRunner",
|
|
7
|
-
"WallstopStudios.DxMessaging"
|
|
8
|
-
],
|
|
9
|
-
"includePlatforms": [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"versionDefines": [],
|
|
23
|
-
"noEngineReferences": false
|
|
1
|
+
{
|
|
2
|
+
"name": "WallstopStudios.DxMessaging.Tests.Runtime",
|
|
3
|
+
"rootNamespace": "DxMessaging.Tests",
|
|
4
|
+
"references": [
|
|
5
|
+
"UnityEngine.TestRunner",
|
|
6
|
+
"UnityEditor.TestRunner",
|
|
7
|
+
"WallstopStudios.DxMessaging"
|
|
8
|
+
],
|
|
9
|
+
"includePlatforms": [],
|
|
10
|
+
"excludePlatforms": [],
|
|
11
|
+
"allowUnsafeCode": false,
|
|
12
|
+
"overrideReferences": true,
|
|
13
|
+
"precompiledReferences": [
|
|
14
|
+
"nunit.framework.dll"
|
|
15
|
+
],
|
|
16
|
+
"autoReferenced": false,
|
|
17
|
+
"defineConstraints": [
|
|
18
|
+
"UNITY_INCLUDE_TESTS"
|
|
19
|
+
],
|
|
20
|
+
"versionDefines": [],
|
|
21
|
+
"noEngineReferences": false
|
|
24
22
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "com.wallstop-studios.dxmessaging",
|
|
3
|
-
"version": "1.0.
|
|
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.
|
|
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
|
-
}
|