fr.jeanf.eventsystem 0.1.70 → 0.1.71
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/TransformEventListener.cs +35 -0
- package/Runtime/Listeners/TransformEventListener.cs.meta +11 -0
- package/Runtime/PingSystem/PingableScriptableObject.cs +0 -2
- package/Runtime/ScriptableObjects/TransformEventChannelSO.cs +16 -0
- package/Runtime/ScriptableObjects/TransformEventChannelSO.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,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,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,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