fr.jeanf.eventsystem 0.1.78 → 0.1.80

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 StringFloatEvent : UnityEvent<string, float>
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 StringFloatEventListener : 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 StringFloatEventChannelSO _channel = default;
28
+
29
+ public StringFloatEvent 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 str, float value)
44
+ {
45
+ OnEventRaised?.Invoke(str, value);
46
+ if(isDebug) Debug.Log($" <string-string> event raised: <{str},{value}>");
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 4c9cb625d8639014e82a57f546541034
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -3,7 +3,7 @@ using UnityEngine.Events;
3
3
 
4
4
  namespace jeanf.EventSystem
5
5
  {
6
- [CreateAssetMenu(menuName = "Events/<Int,Bool> Event Channel")]
6
+ [CreateAssetMenu(menuName = "Events/Advanced/<Int,Bool> Event Channel")]
7
7
 
8
8
  public class IntBoolEventChannelSO : DescriptionBaseSO
9
9
  {
@@ -3,7 +3,7 @@ using UnityEngine.Events;
3
3
 
4
4
  namespace jeanf.EventSystem
5
5
  {
6
- [CreateAssetMenu(menuName = "Events/<Int,Float> Event Channel")]
6
+ [CreateAssetMenu(menuName = "Events/Advanced/<Int,Float> Event Channel")]
7
7
 
8
8
  public class IntFloatEventChannelSO : DescriptionBaseSO
9
9
  {
@@ -3,7 +3,7 @@ using UnityEngine.Events;
3
3
 
4
4
  namespace jeanf.EventSystem
5
5
  {
6
- [CreateAssetMenu(menuName = "Events/<Int,GameObject> Event Channel")]
6
+ [CreateAssetMenu(menuName = "Events/Advanced/<Int,GameObject> Event Channel")]
7
7
 
8
8
  public class IntGameObjectEventChannelSO : DescriptionBaseSO
9
9
  {
@@ -3,7 +3,7 @@ using UnityEngine.Events;
3
3
 
4
4
  namespace jeanf.EventSystem
5
5
  {
6
- [CreateAssetMenu(menuName = "Events/<Int,Int> Event Channel")]
6
+ [CreateAssetMenu(menuName = "Events/Advanced/<Int,Int> Event Channel")]
7
7
 
8
8
  public class IntIntEventChannelSO : DescriptionBaseSO
9
9
  {
@@ -3,7 +3,7 @@ using UnityEngine.Events;
3
3
 
4
4
  namespace jeanf.EventSystem
5
5
  {
6
- [CreateAssetMenu(menuName = "Events/<Int,String> Event Channel")]
6
+ [CreateAssetMenu(menuName = "Events/Advanced/<Int,String> Event Channel")]
7
7
 
8
8
  public class IntStringEventChannelSO : DescriptionBaseSO
9
9
  {
@@ -0,0 +1,17 @@
1
+ using UnityEngine;
2
+ using UnityEngine.Events;
3
+
4
+ namespace jeanf.EventSystem
5
+ {
6
+ [CreateAssetMenu(menuName = "Events/Advanced/<string,float> Event Channel")]
7
+
8
+ public class StringFloatEventChannelSO : DescriptionBaseSO
9
+ {
10
+ public UnityAction<string, float> OnEventRaised;
11
+
12
+ public void RaiseEvent(string str, float value)
13
+ {
14
+ OnEventRaised?.Invoke(str, value);
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 49cda673f4bfce940b74f7ef2ec59239
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -3,7 +3,7 @@ using UnityEngine.Events;
3
3
 
4
4
  namespace jeanf.EventSystem
5
5
  {
6
- [CreateAssetMenu(menuName = "Events/<string,string> Event Channel")]
6
+ [CreateAssetMenu(menuName = "Events/Advanced/<string,string> Event Channel")]
7
7
 
8
8
  public class StringStringEventChannelSO : DescriptionBaseSO
9
9
  {
@@ -0,0 +1,22 @@
1
+ using UnityEngine;
2
+
3
+ namespace jeanf.EventSystem
4
+ {
5
+ public class StringFloatEventSender : 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 StringFloatEventChannelSO stringStringMessageChannel;
15
+
16
+ public void SendIntInt(string str, float value)
17
+ {
18
+ stringStringMessageChannel.RaiseEvent(str, value);
19
+ }
20
+ }
21
+ }
22
+
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: adf5537601212a24d86cf1d7776deb6e
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.78",
3
+ "version":"0.1.80",
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",