fr.jeanf.eventsystem 0.1.71 → 0.1.72
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.
- package/Runtime/Listeners/IntBoolEventListener.cs +49 -0
- package/Runtime/Listeners/IntBoolEventListener.cs.meta +11 -0
- package/Runtime/ScriptableObjects/IntBoolEventChannelSO.cs +17 -0
- package/Runtime/ScriptableObjects/IntBoolEventChannelSO.cs.meta +11 -0
- package/Runtime/SenderInterfaces/IntBoolEventSender.cs +22 -0
- package/Runtime/SenderInterfaces/IntBoolEventSender.cs.meta +11 -0
- package/package.json +1 -1
|
@@ -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 IntBoolEvent : UnityEvent<int, 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 IntBoolEventListener : 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 IntBoolEventChannelSO _channel = default;
|
|
28
|
+
|
|
29
|
+
public IntBoolEvent 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(int nb, bool value)
|
|
44
|
+
{
|
|
45
|
+
OnEventRaised?.Invoke(nb, value);
|
|
46
|
+
if(isDebug) Debug.Log($" int-bool event raised: <{nb},{value}>");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using UnityEngine.Events;
|
|
3
|
+
|
|
4
|
+
namespace jeanf.EventSystem
|
|
5
|
+
{
|
|
6
|
+
[CreateAssetMenu(menuName = "Events/<Int,Bool> Event Channel")]
|
|
7
|
+
|
|
8
|
+
public class IntBoolEventChannelSO : DescriptionBaseSO
|
|
9
|
+
{
|
|
10
|
+
public UnityAction<int, bool> OnEventRaised;
|
|
11
|
+
|
|
12
|
+
public void RaiseEvent(int nb, bool value)
|
|
13
|
+
{
|
|
14
|
+
OnEventRaised?.Invoke(nb, value);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
|
|
3
|
+
namespace jeanf.EventSystem
|
|
4
|
+
{
|
|
5
|
+
public class IntBoolEventSender : 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 IntBoolEventChannelSO boolMessageChannel;
|
|
15
|
+
|
|
16
|
+
public void SendBool(int nb, bool value)
|
|
17
|
+
{
|
|
18
|
+
boolMessageChannel.RaiseEvent(nb, value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
package/package.json
CHANGED