fr.jeanf.eventsystem 0.1.89 → 0.1.91

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,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,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/Decimal 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:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fr.jeanf.eventsystem",
3
- "version": "0.1.89",
3
+ "version": "0.1.91",
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",