fr.jeanf.eventsystem 0.1.74 → 0.1.76

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.
@@ -0,0 +1,49 @@
1
+ using UnityEngine;
2
+ using UnityEngine.Events;
3
+
4
+ /// <summary>
5
+ /// To use a generic UnityEvent type you must override the generic type.
6
+ /// </summary>
7
+ namespace jeanf.EventSystem
8
+ {
9
+ [System.Serializable]
10
+ public class StringStringEvent : UnityEvent<string, string>
11
+ {
12
+
13
+ }
14
+
15
+ /// <summary>
16
+ /// A flexible handler for int events in the form of a MonoBehaviour. Responses can be connected directly from the Unity Inspector.
17
+ /// </summary>
18
+ public class StringStringEventListener : MonoBehaviour, IDebugBehaviour
19
+ {
20
+ public bool isDebug
21
+ {
22
+ get => _isDebug;
23
+ set => _isDebug = value;
24
+ }
25
+ [SerializeField] private bool _isDebug = false;
26
+
27
+ [SerializeField] private StringStringEventChannelSO _channel = default;
28
+
29
+ public StringStringEvent OnEventRaised;
30
+
31
+ private void OnEnable()
32
+ {
33
+ if (_channel != null)
34
+ _channel.OnEventRaised += Respond;
35
+ }
36
+
37
+ private void OnDisable()
38
+ {
39
+ if (_channel != null)
40
+ _channel.OnEventRaised -= Respond;
41
+ }
42
+
43
+ private void Respond(string str1, string str2)
44
+ {
45
+ OnEventRaised?.Invoke(str1, str2);
46
+ if(isDebug) Debug.Log($" <string-string> event raised: <{str1},{str2}>");
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: e6fcb826d3e47a540aeccb1059121b8e
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -13,7 +13,10 @@ namespace jeanf.EventSystem
13
13
  [SerializeField] private bool _isDebug = false;
14
14
 
15
15
  [SerializeField] private VoidEventChannelSO refreshPingableObjects;
16
- [ReadOnly] [SerializeField] private string id = Guid.NewGuid().ToString();
16
+ #if UNITY_EDITOR
17
+ [ReadOnly]
18
+ #endif
19
+ [SerializeField] private string id = Guid.NewGuid().ToString();
17
20
 
18
21
  public ScriptableObjectEventChannelSO channel
19
22
  {
@@ -0,0 +1,17 @@
1
+ using UnityEngine;
2
+ using UnityEngine.Events;
3
+
4
+ namespace jeanf.EventSystem
5
+ {
6
+ [CreateAssetMenu(menuName = "Events/<string,string> Event Channel")]
7
+
8
+ public class StringStringEventChannelSO : DescriptionBaseSO
9
+ {
10
+ public UnityAction<string, string> OnEventRaised;
11
+
12
+ public void RaiseEvent(string str1, string str2)
13
+ {
14
+ OnEventRaised?.Invoke(str1, str2);
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 4b195c8917e79154097e941f64a0d512
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -2,7 +2,7 @@ using UnityEngine;
2
2
 
3
3
  namespace jeanf.EventSystem
4
4
  {
5
- public class BoolEventSender : MonoBehaviour, IDebugBehaviour
5
+ public class StringEventSender : MonoBehaviour, IDebugBehaviour
6
6
  {
7
7
  public bool isDebug
8
8
  {
@@ -11,11 +11,11 @@ namespace jeanf.EventSystem
11
11
  }
12
12
  [SerializeField] private bool _isDebug = false;
13
13
 
14
- [field: Header("Broadcasting on:")] public BoolEventChannelSO boolMessageChannel;
14
+ [field: Header("Broadcasting on:")] public StringEventChannelSO stringMessageChannel;
15
15
 
16
- public void SendBool(bool value)
16
+ public void SendString(string value)
17
17
  {
18
- boolMessageChannel.RaiseEvent(value);
18
+ stringMessageChannel.RaiseEvent(value);
19
19
  }
20
20
  }
21
21
  }
@@ -0,0 +1,22 @@
1
+ using UnityEngine;
2
+
3
+ namespace jeanf.EventSystem
4
+ {
5
+ public class StringStringEventSender : MonoBehaviour, IDebugBehaviour
6
+ {
7
+ public bool isDebug
8
+ {
9
+ get => _isDebug;
10
+ set => _isDebug = value;
11
+ }
12
+ [SerializeField] private bool _isDebug = false;
13
+
14
+ [field: Header("Broadcasting on:")] public StringStringEventChannelSO stringStringMessageChannel;
15
+
16
+ public void SendIntInt(string str1, string str2)
17
+ {
18
+ stringStringMessageChannel.RaiseEvent(str1, str2);
19
+ }
20
+ }
21
+ }
22
+
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: dc5bfc100e226584fa470b749148e685
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name":"fr.jeanf.eventsystem",
3
- "version":"0.1.74",
3
+ "version":"0.1.76",
4
4
  "displayName":"Event System",
5
5
  "description":"This package contains a basic Event System based on Scriptable Objects as communication medium",
6
6
  "unity": "2021.3",