fr.jeanf.eventsystem 0.1.94 → 0.1.96

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,50 @@
1
+ using System;
2
+ using UnityEngine;
3
+ using UnityEngine.Events;
4
+
5
+ /// <summary>
6
+ /// To use a generic UnityEvent type you must override the generic type.
7
+ /// </summary>
8
+ namespace jeanf.EventSystem
9
+ {
10
+ [System.Serializable]
11
+ public class IntEnumEvent : UnityEvent<int, Enum>
12
+ {
13
+
14
+ }
15
+
16
+ /// <summary>
17
+ /// A flexible handler for int events in the form of a MonoBehaviour. Responses can be connected directly from the Unity Inspector.
18
+ /// </summary>
19
+ public class IntEnumEventListener : MonoBehaviour, IDebugBehaviour
20
+ {
21
+ public bool isDebug
22
+ {
23
+ get => _isDebug;
24
+ set => _isDebug = value;
25
+ }
26
+ [SerializeField] private bool _isDebug = false;
27
+
28
+ [SerializeField] private IntEnumEventChannelSO _channel = default;
29
+
30
+ public IntEnumEvent OnEventRaised;
31
+
32
+ private void OnEnable()
33
+ {
34
+ if (_channel != null)
35
+ _channel.OnEventRaised += Respond;
36
+ }
37
+
38
+ private void OnDisable()
39
+ {
40
+ if (_channel != null)
41
+ _channel.OnEventRaised -= Respond;
42
+ }
43
+
44
+ private void Respond(int nb, Enum value)
45
+ {
46
+ OnEventRaised?.Invoke(nb, value);
47
+ if(isDebug) Debug.Log($" int-bool event raised: <{nb},{value}>");
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 20a10c4d556620f4882b58ec857a3227
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -26,7 +26,7 @@ namespace jeanf.EventSystem
26
26
  }
27
27
  [SerializeField] private bool _isDebug = false;
28
28
 
29
- [SerializeField] private TimelineTriggerEventChannelSO _channel = default;
29
+ [SerializeField] private TimelineTriggerEventChannelSO _channel;
30
30
  [SerializeField] private PlayableDirector _playableDirectorToControl;
31
31
  [Tooltip("Use this if you want to override the timeline assigned to the playable director.")]
32
32
  [SerializeField] private bool assignTimelineToPlayableDirector = true;
@@ -0,0 +1,18 @@
1
+ using System;
2
+ using UnityEngine;
3
+ using UnityEngine.Events;
4
+
5
+ namespace jeanf.EventSystem
6
+ {
7
+ [CreateAssetMenu(menuName = "Events/Advanced/<Int,Enum> Event Channel")]
8
+
9
+ public class IntEnumEventChannelSO : DescriptionBaseSO
10
+ {
11
+ public UnityAction<int, Enum> OnEventRaised;
12
+
13
+ public void RaiseEvent(int nb, Enum value)
14
+ {
15
+ OnEventRaised?.Invoke(nb, value);
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: ac39704fae6958d4396fd823796f97cd
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,24 @@
1
+ using System;
2
+ using UnityEngine;
3
+
4
+ namespace jeanf.EventSystem
5
+ {
6
+ public class IntEnumEventSender : MonoBehaviour, IDebugBehaviour
7
+ {
8
+ public bool isDebug
9
+ {
10
+ get => _isDebug;
11
+ set => _isDebug = value;
12
+ }
13
+
14
+ [SerializeField] private bool _isDebug = false;
15
+
16
+ [field: Header("Broadcasting on:")] public IntEnumEventChannelSO intEnumMessageChannel;
17
+
18
+ public void SendIntEnum(int nb, Enum value)
19
+ {
20
+ intEnumMessageChannel.RaiseEvent(nb, value);
21
+ }
22
+ }
23
+ }
24
+
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: c6b09f9e56b867948a7d9c46f79a3b05
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.94",
3
+ "version": "0.1.96",
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",