fr.jeanf.eventsystem 0.1.88 → 0.1.89
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/Editor/SendStringBoolEventOnClick.cs +40 -0
- package/Runtime/Editor/SendStringBoolEventOnClick.cs.meta +11 -0
- package/Runtime/Listeners/StringBoolEventListener.cs +49 -0
- package/Runtime/Listeners/StringBoolEventListener.cs.meta +11 -0
- package/Runtime/ScriptableObjects/Advanced/StringBoolEventChannelSO.cs +18 -0
- package/Runtime/ScriptableObjects/Advanced/StringBoolEventChannelSO.cs.meta +11 -0
- package/Runtime/SenderInterfaces/StringBoolEventSender.cs +21 -0
- package/Runtime/SenderInterfaces/StringBoolEventSender.cs.meta +11 -0
- package/package.json +1 -1
- /package/Runtime/ScriptableObjects/{InputActionIntEventChannelSO.cs → Advanced/InputActionIntEventChannelSO.cs} +0 -0
- /package/Runtime/ScriptableObjects/{InputActionIntEventChannelSO.cs.meta → Advanced/InputActionIntEventChannelSO.cs.meta} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#if UNITY_EDITOR
|
|
2
|
+
using UnityEditor;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace jeanf.EventSystem
|
|
6
|
+
{
|
|
7
|
+
public class SendStringBoolEventOnClick : MonoBehaviour
|
|
8
|
+
{
|
|
9
|
+
|
|
10
|
+
[Header("Broadcasting on:")]
|
|
11
|
+
[SerializeField]
|
|
12
|
+
private StringBoolEventChannelSO TestChannel;
|
|
13
|
+
|
|
14
|
+
[Space(20)]
|
|
15
|
+
[SerializeField] private bool valueToSend = false;
|
|
16
|
+
[SerializeField] private string textToSend;
|
|
17
|
+
|
|
18
|
+
public void CallFunction()
|
|
19
|
+
{
|
|
20
|
+
TestChannel.RaiseEvent(textToSend, valueToSend);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
[CustomEditor(typeof(SendStringBoolEventOnClick))]
|
|
25
|
+
public class StringBoolEventOnClickEditor : Editor
|
|
26
|
+
{
|
|
27
|
+
override public void OnInspectorGUI()
|
|
28
|
+
{
|
|
29
|
+
DrawDefaultInspector();
|
|
30
|
+
var eventToSend = (SendStringBoolEventOnClick)target;
|
|
31
|
+
if (GUILayout.Button("Send bool", GUILayout.Height(30)))
|
|
32
|
+
{
|
|
33
|
+
eventToSend.CallFunction(); // how do i call this?
|
|
34
|
+
}
|
|
35
|
+
GUILayout.Space(10);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
#endif
|
|
40
|
+
|
|
@@ -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 StringBoolEvent : UnityEvent<string, 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 StringBoolEventListener : 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 StringBoolEventChannelSO _channel = default;
|
|
28
|
+
|
|
29
|
+
public StringBoolEvent 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(string str, bool value)
|
|
44
|
+
{
|
|
45
|
+
OnEventRaised?.Invoke(str, value);
|
|
46
|
+
if (isDebug) Debug.Log($" int-bool event raised: <{str},{value}>");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
using UnityEngine.Events;
|
|
5
|
+
|
|
6
|
+
namespace jeanf.EventSystem
|
|
7
|
+
{
|
|
8
|
+
[CreateAssetMenu(menuName = "Events/Advanced/<string,bool> Event Channel")]
|
|
9
|
+
public class StringBoolEventChannelSO : DescriptionBaseSO
|
|
10
|
+
{
|
|
11
|
+
public UnityAction<string, bool> OnEventRaised;
|
|
12
|
+
|
|
13
|
+
public void RaiseEvent(string str1, bool value)
|
|
14
|
+
{
|
|
15
|
+
OnEventRaised?.Invoke(str1, value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
|
|
3
|
+
namespace jeanf.EventSystem
|
|
4
|
+
{
|
|
5
|
+
public class StringBoolEventSender : 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 StringBoolEventChannelSO stringBoolMessageChannel;
|
|
15
|
+
|
|
16
|
+
public void SendIntBool(string str, bool value)
|
|
17
|
+
{
|
|
18
|
+
stringBoolMessageChannel.RaiseEvent(str, value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
package/package.json
CHANGED
|
File without changes
|