fr.jeanf.eventsystem 0.1.63 → 0.1.65
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/FloatEventListener.cs +41 -0
- package/Runtime/Listeners/FloatEventListener.cs.meta +11 -0
- package/Runtime/ScriptableObjects/FloatEventChannelSO.cs +21 -0
- package/Runtime/ScriptableObjects/FloatEventChannelSO.cs.meta +11 -0
- package/Runtime/SenderInterfaces/FloatEventSender.cs +19 -0
- package/Runtime/SenderInterfaces/FloatEventSender.cs.meta +11 -0
- package/Runtime/SenderInterfaces/IFoatlEventSender.cs +10 -0
- package/Runtime/SenderInterfaces/IFoatlEventSender.cs.meta +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using UnityEngine.Events;
|
|
3
|
+
|
|
4
|
+
namespace jeanf.EventSystem
|
|
5
|
+
{
|
|
6
|
+
[System.Serializable]
|
|
7
|
+
public class FloatEvent : UnityEvent<float>
|
|
8
|
+
{
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public class FloatEventListener : MonoBehaviour
|
|
13
|
+
{
|
|
14
|
+
public FloatEventChannelSO _channel = default;
|
|
15
|
+
|
|
16
|
+
public FloatEvent OnFloatEventRaised;
|
|
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(float value)
|
|
31
|
+
{
|
|
32
|
+
OnFloatEventRaised?.Invoke(value);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public FloatEventListener(FloatEventChannelSO _channel, FloatEvent OnFloatEventRaised)
|
|
36
|
+
{
|
|
37
|
+
this._channel = _channel;
|
|
38
|
+
this.OnFloatEventRaised = OnFloatEventRaised;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -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/Float Event Channel")]
|
|
11
|
+
public class FloatEventChannelSO : DescriptionBaseSO
|
|
12
|
+
{
|
|
13
|
+
public UnityAction<float> OnEventRaised;
|
|
14
|
+
|
|
15
|
+
public void RaiseEvent(float value)
|
|
16
|
+
{
|
|
17
|
+
if (OnEventRaised != null)
|
|
18
|
+
OnEventRaised.Invoke(value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
using jeanf.EventSystem;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
public class FloatEventSender : MonoBehaviour, IDebugBehaviour
|
|
5
|
+
{
|
|
6
|
+
public bool isDebug
|
|
7
|
+
{
|
|
8
|
+
get => _isDebug;
|
|
9
|
+
set => _isDebug = value;
|
|
10
|
+
}
|
|
11
|
+
[SerializeField] private bool _isDebug = false;
|
|
12
|
+
|
|
13
|
+
[field: Header("Broadcasting on:")] public FloatEventChannelSO floatMessageChannel;
|
|
14
|
+
|
|
15
|
+
public void SendFloat(float value)
|
|
16
|
+
{
|
|
17
|
+
floatMessageChannel.RaiseEvent(value);
|
|
18
|
+
}
|
|
19
|
+
}
|
package/package.json
CHANGED