fr.jeanf.eventsystem 0.1.97 → 0.1.99
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/StringListEventOnClick.cs +39 -0
- package/Runtime/Editor/StringListEventOnClick.cs.meta +11 -0
- package/Runtime/Listeners/StringListEventListener.cs +43 -0
- package/Runtime/Listeners/StringListEventListener.cs.meta +11 -0
- package/Runtime/SenderInterfaces/StringListEventSender.cs +23 -0
- package/Runtime/SenderInterfaces/StringListEventSender.cs.meta +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#if UNITY_EDITOR
|
|
2
|
+
using System.Collections;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEditor;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace jeanf.EventSystem
|
|
8
|
+
{
|
|
9
|
+
public class StringListEventOnClick : MonoBehaviour
|
|
10
|
+
{
|
|
11
|
+
[Header("Broadcasting On:")]
|
|
12
|
+
[SerializeField] private StringListEventChannelSO testChannel;
|
|
13
|
+
|
|
14
|
+
[Space(20)]
|
|
15
|
+
[SerializeField] private List<string> valueToSend;
|
|
16
|
+
|
|
17
|
+
public void CallFunction()
|
|
18
|
+
{
|
|
19
|
+
testChannel.RaiseEvent(valueToSend);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[CustomEditor(typeof(StringListEventOnClick))]
|
|
24
|
+
public class SendStringEventOnClickEditor: Editor
|
|
25
|
+
{
|
|
26
|
+
public override void OnInspectorGUI()
|
|
27
|
+
{
|
|
28
|
+
DrawDefaultInspector();
|
|
29
|
+
var eventToSend = (StringListEventOnClick)target;
|
|
30
|
+
if(GUILayout.Button("Send String List", GUILayout.Height(30)))
|
|
31
|
+
{
|
|
32
|
+
eventToSend.CallFunction();
|
|
33
|
+
}
|
|
34
|
+
GUILayout.Space(10);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
#endif
|
|
39
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
using UnityEngine.Events;
|
|
5
|
+
|
|
6
|
+
namespace jeanf.EventSystem
|
|
7
|
+
{
|
|
8
|
+
[System.Serializable]
|
|
9
|
+
public class StringListEvent: UnityEvent<List<string>>
|
|
10
|
+
{
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public class StringListEventListener : MonoBehaviour
|
|
15
|
+
{
|
|
16
|
+
public StringListEventChannelSO _channel = default;
|
|
17
|
+
|
|
18
|
+
public StringListEvent OnStringListEventRaised;
|
|
19
|
+
|
|
20
|
+
private void OnEnable()
|
|
21
|
+
{
|
|
22
|
+
if (_channel != null)
|
|
23
|
+
_channel.OnEventRaised += Respond;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private void OnDisable()
|
|
27
|
+
{
|
|
28
|
+
if (_channel != null)
|
|
29
|
+
_channel.OnEventRaised -= Respond;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private void Respond(List<string> list)
|
|
33
|
+
{
|
|
34
|
+
OnStringListEventRaised?.Invoke(list);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public StringListEventListener(StringListEventChannelSO _channel, StringListEvent OnStringListEventRaised)
|
|
38
|
+
{
|
|
39
|
+
this._channel = _channel;
|
|
40
|
+
this.OnStringListEventRaised = OnStringListEventRaised;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace jeanf.EventSystem
|
|
6
|
+
{
|
|
7
|
+
public class StringListEventSender : MonoBehaviour, IDebugBehaviour
|
|
8
|
+
{
|
|
9
|
+
public bool isDebug
|
|
10
|
+
{
|
|
11
|
+
get => _isDebug;
|
|
12
|
+
set => _isDebug = value;
|
|
13
|
+
}
|
|
14
|
+
[SerializeField] private bool _isDebug = false;
|
|
15
|
+
[field: Header("Broadcasting on:")] public StringListEventChannelSO stringListEventChannel;
|
|
16
|
+
|
|
17
|
+
public void SendStringList(List<string> list)
|
|
18
|
+
{
|
|
19
|
+
stringListEventChannel.RaiseEvent(list);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
}
|
package/package.json
CHANGED