fr.jeanf.eventsystem 0.1.70 → 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/Listeners/TransformEventListener.cs +35 -0
- package/Runtime/Listeners/TransformEventListener.cs.meta +11 -0
- package/Runtime/PingSystem/PingableScriptableObject.cs +0 -2
- package/Runtime/ScriptableObjects/IntBoolEventChannelSO.cs +17 -0
- package/Runtime/ScriptableObjects/IntBoolEventChannelSO.cs.meta +11 -0
- package/Runtime/ScriptableObjects/TransformEventChannelSO.cs +16 -0
- package/Runtime/ScriptableObjects/TransformEventChannelSO.cs.meta +11 -0
- package/Runtime/SenderInterfaces/IntBoolEventSender.cs +22 -0
- package/Runtime/SenderInterfaces/IntBoolEventSender.cs.meta +11 -0
- package/Runtime/SenderInterfaces/TransformEventSender.cs +44 -0
- package/Runtime/SenderInterfaces/TransformEventSender.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,35 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
using UnityEngine.Events;
|
|
4
|
+
|
|
5
|
+
namespace jeanf.EventSystem
|
|
6
|
+
{
|
|
7
|
+
[System.Serializable]
|
|
8
|
+
public class TransformEvent : UnityEvent<Transform>
|
|
9
|
+
{
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
public class TransformEventListener : MonoBehaviour
|
|
13
|
+
{
|
|
14
|
+
[Header("Receiving on channel:")]
|
|
15
|
+
[SerializeField] private TransformEventChannelSO _channel = default;
|
|
16
|
+
|
|
17
|
+
public UnityEvent<Transform> OnEventRaised;
|
|
18
|
+
|
|
19
|
+
private void OnEnable()
|
|
20
|
+
{
|
|
21
|
+
if (_channel != null) _channel.OnEventRaised += Respond;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private void OnDisable()
|
|
25
|
+
{
|
|
26
|
+
if (_channel != null) _channel.OnEventRaised -= Respond;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private void Respond( Transform transform)
|
|
30
|
+
{
|
|
31
|
+
OnEventRaised?.Invoke(transform);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -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,16 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using UnityEngine.Events;
|
|
3
|
+
|
|
4
|
+
namespace jeanf.EventSystem
|
|
5
|
+
{
|
|
6
|
+
[CreateAssetMenu(menuName = "Events/Transform Event Channel")]
|
|
7
|
+
public class TransformEventChannelSO : DescriptionBaseSO
|
|
8
|
+
{
|
|
9
|
+
public UnityAction<Transform> OnEventRaised;
|
|
10
|
+
|
|
11
|
+
public void RaiseEvent(Transform value)
|
|
12
|
+
{
|
|
13
|
+
OnEventRaised?.Invoke(value);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -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
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
using UnityEngine.Serialization;
|
|
4
|
+
|
|
5
|
+
namespace jeanf.EventSystem
|
|
6
|
+
{
|
|
7
|
+
public class TransformEventSender : MonoBehaviour, IDebugBehaviour
|
|
8
|
+
{
|
|
9
|
+
public bool isDebug
|
|
10
|
+
{
|
|
11
|
+
get => _isDebug;
|
|
12
|
+
set => _isDebug = value;
|
|
13
|
+
}
|
|
14
|
+
[SerializeField] private bool _isDebug = false;
|
|
15
|
+
[SerializeField] private bool _sendTransfromOnAwake;
|
|
16
|
+
[SerializeField] private bool _sendCustomTransform;
|
|
17
|
+
[DrawIf("_sendCustomTransform", true, ComparisonType.Equals)]
|
|
18
|
+
[SerializeField] private Transform _transform;
|
|
19
|
+
|
|
20
|
+
[field: Header("Broadcasting on:")] public TransformEventChannelSO transformMessageChannel;
|
|
21
|
+
|
|
22
|
+
public void SendTransform(Transform value)
|
|
23
|
+
{
|
|
24
|
+
transformMessageChannel.RaiseEvent(value);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public void SendCustomTransform()
|
|
28
|
+
{
|
|
29
|
+
SendTransform(_transform);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private void Awake()
|
|
33
|
+
{
|
|
34
|
+
if(!_sendTransfromOnAwake) return;
|
|
35
|
+
|
|
36
|
+
if(!_sendCustomTransform)SendTransform(this.gameObject.transform);
|
|
37
|
+
else
|
|
38
|
+
{
|
|
39
|
+
SendTransform(_transform);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
package/package.json
CHANGED