fr.jeanf.eventsystem 0.1.88 → 0.1.90

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,36 @@
1
+ #if UNITY_EDITOR
2
+
3
+ using jeanf.EventSystem;
4
+ using UnityEditor;
5
+ using UnityEngine;
6
+
7
+ namespace jeanf.EventSystem
8
+ {
9
+ public class SendDecimalEventOnClick : MonoBehaviour
10
+ {
11
+
12
+ [Header("Broadcasting on:")] [SerializeField]
13
+ private DecimalEventChannelSO TestChannel;
14
+
15
+ [Space(20)]
16
+ [SerializeField] private decimal messageToSend = 1;
17
+ public void CallFunction()
18
+ {
19
+ TestChannel.RaiseEvent(messageToSend);
20
+ }
21
+ }
22
+
23
+ [CustomEditor(typeof(SendDecimalEventOnClick))]
24
+ public class DecimalEventOnClickEditor : Editor {
25
+ override public void OnInspectorGUI () {
26
+ DrawDefaultInspector();
27
+ var eventToSend = (SendDecimalEventOnClick)target;
28
+ if(GUILayout.Button("Send int", GUILayout.Height(30))) {
29
+ eventToSend.CallFunction(); // how do i call this?
30
+ }
31
+ GUILayout.Space(10);
32
+ }
33
+ }
34
+ }
35
+
36
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: c8c9f17f0fce63a43a60494d4e212b47
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,40 @@
1
+ #if UNITY_EDITOR
2
+ using UnityEditor;
3
+ using UnityEngine;
4
+
5
+ namespace jeanf.EventSystem
6
+ {
7
+ public class SendStringBoolEventOnClick : MonoBehaviour
8
+ {
9
+
10
+ [Header("Broadcasting on:")]
11
+ [SerializeField]
12
+ private StringBoolEventChannelSO TestChannel;
13
+
14
+ [Space(20)]
15
+ [SerializeField] private bool valueToSend = false;
16
+ [SerializeField] private string textToSend;
17
+
18
+ public void CallFunction()
19
+ {
20
+ TestChannel.RaiseEvent(textToSend, valueToSend);
21
+ }
22
+ }
23
+
24
+ [CustomEditor(typeof(SendStringBoolEventOnClick))]
25
+ public class StringBoolEventOnClickEditor : Editor
26
+ {
27
+ override public void OnInspectorGUI()
28
+ {
29
+ DrawDefaultInspector();
30
+ var eventToSend = (SendStringBoolEventOnClick)target;
31
+ if (GUILayout.Button("Send bool", GUILayout.Height(30)))
32
+ {
33
+ eventToSend.CallFunction(); // how do i call this?
34
+ }
35
+ GUILayout.Space(10);
36
+ }
37
+ }
38
+ }
39
+ #endif
40
+
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 2e0ea87f855578f408f0ac8f5c749d2d
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,41 @@
1
+ using UnityEngine;
2
+ using UnityEngine.Events;
3
+ using UnityEngine.Serialization;
4
+
5
+ namespace jeanf.EventSystem
6
+ {
7
+ [System.Serializable]
8
+ public class DecimalEvent : UnityEvent<decimal>
9
+ {
10
+
11
+ }
12
+
13
+ public class DecimalEventListener : MonoBehaviour
14
+ {
15
+ public DecimalEventChannelSO _channel = default;
16
+ public DecimalEvent OnDecimalEventRaised;
17
+
18
+ private void OnEnable()
19
+ {
20
+ if (_channel != null)
21
+ _channel.OnEventRaised += Respond;
22
+ }
23
+
24
+ private void OnDisable()
25
+ {
26
+ if (_channel != null)
27
+ _channel.OnEventRaised -= Respond;
28
+ }
29
+
30
+ private void Respond(decimal value)
31
+ {
32
+ OnDecimalEventRaised?.Invoke(value);
33
+ }
34
+
35
+ public DecimalEventListener(DecimalEventChannelSO _channel, DecimalEvent onDecimalEventRaised)
36
+ {
37
+ this._channel = _channel;
38
+ this.OnDecimalEventRaised = onDecimalEventRaised;
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 16cabf22a4499bf42adbd01a00fb3a62
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -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 StringBoolEvent : UnityEvent<string, bool>
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 StringBoolEventListener : 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 StringBoolEventChannelSO _channel = default;
28
+
29
+ public StringBoolEvent 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, bool value)
44
+ {
45
+ OnEventRaised?.Invoke(str, value);
46
+ if (isDebug) Debug.Log($" int-bool event raised: <{str},{value}>");
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: b12953493941dfc428330a22aa79dc8a
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,18 @@
1
+ using System.Collections;
2
+ using System.Collections.Generic;
3
+ using UnityEngine;
4
+ using UnityEngine.Events;
5
+
6
+ namespace jeanf.EventSystem
7
+ {
8
+ [CreateAssetMenu(menuName = "Events/Advanced/<string,bool> Event Channel")]
9
+ public class StringBoolEventChannelSO : DescriptionBaseSO
10
+ {
11
+ public UnityAction<string, bool> OnEventRaised;
12
+
13
+ public void RaiseEvent(string str1, bool value)
14
+ {
15
+ OnEventRaised?.Invoke(str1, value);
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 2f7b9df1ba236c54c813672d95e11b13
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,21 @@
1
+ using UnityEngine;
2
+ using UnityEngine.Events;
3
+
4
+ /// <summary>
5
+ /// This class is used for Events that have one int argument.
6
+ /// Example: An Achievement unlock event, where the int is the Achievement ID.
7
+ /// </summary>
8
+ namespace jeanf.EventSystem
9
+ {
10
+ [CreateAssetMenu(menuName = "Events/Float Event Channel")]
11
+ public class DecimalEventChannelSO : DescriptionBaseSO
12
+ {
13
+ public UnityAction<decimal> OnEventRaised;
14
+
15
+ public void RaiseEvent(decimal value)
16
+ {
17
+ if (OnEventRaised != null)
18
+ OnEventRaised.Invoke(value);
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 4278b3abf9583cf4bbdac0280f991dca
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,22 @@
1
+ using jeanf.EventSystem;
2
+ using UnityEngine;
3
+
4
+ namespace jeanf.EventSystem
5
+ {
6
+ public class DecimalEventSender : MonoBehaviour, IDebugBehaviour
7
+ {
8
+ public bool isDebug
9
+ {
10
+ get => _isDebug;
11
+ set => _isDebug = value;
12
+ }
13
+ [SerializeField] private bool _isDebug = false;
14
+
15
+ [field: Header("Broadcasting on:")] public DecimalEventChannelSO floatMessageChannel;
16
+
17
+ public void SendFloat(decimal value)
18
+ {
19
+ floatMessageChannel.RaiseEvent(value);
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 5547a1413cb31094bbcacbabb296b09a
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,21 @@
1
+ using UnityEngine;
2
+
3
+ namespace jeanf.EventSystem
4
+ {
5
+ public class StringBoolEventSender : 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 StringBoolEventChannelSO stringBoolMessageChannel;
15
+
16
+ public void SendIntBool(string str, bool value)
17
+ {
18
+ stringBoolMessageChannel.RaiseEvent(str, value);
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: b67cfcdf3c282ad4b8e1eb54b358bfe7
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.88",
3
+ "version": "0.1.90",
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",