fr.jeanf.eventsystem 0.1.87 → 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/Editor/SendTimelineTriggerEventOnClick.cs +38 -0
- package/Runtime/Editor/SendTimelineTriggerEventOnClick.cs.meta +11 -0
- package/Runtime/Listeners/StringBoolEventListener.cs +49 -0
- package/Runtime/Listeners/StringBoolEventListener.cs.meta +11 -0
- package/Runtime/Listeners/TimelineTriggerEventListener.cs +66 -0
- package/Runtime/Listeners/TimelineTriggerEventListener.cs.meta +11 -0
- package/Runtime/ScriptableObjects/Advanced/StringBoolEventChannelSO.cs +18 -0
- package/Runtime/ScriptableObjects/Advanced/StringBoolEventChannelSO.cs.meta +11 -0
- package/Runtime/ScriptableObjects/Advanced/TimelineTriggerEventChannelSO.cs +18 -0
- package/Runtime/ScriptableObjects/Advanced/TimelineTriggerEventChannelSO.cs.meta +11 -0
- package/Runtime/SenderInterfaces/StringBoolEventSender.cs +21 -0
- package/Runtime/SenderInterfaces/StringBoolEventSender.cs.meta +11 -0
- package/Runtime/SenderInterfaces/TimelineBoolEventSender.cs +23 -0
- package/Runtime/SenderInterfaces/TimelineBoolEventSender.cs.meta +11 -0
- package/Runtime/SenderInterfaces/TransformEventSender.cs +2 -2
- package/TimelineTriggerChannelSO.asset +16 -0
- package/TimelineTriggerChannelSO.asset.meta +8 -0
- package/package.json +2 -2
- /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,38 @@
|
|
|
1
|
+
#if UNITY_EDITOR
|
|
2
|
+
|
|
3
|
+
using jeanf.EventSystem;
|
|
4
|
+
using UnityEditor;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
using UnityEngine.Playables;
|
|
7
|
+
|
|
8
|
+
namespace jeanf.EventSystem
|
|
9
|
+
{
|
|
10
|
+
public class SendTimelineTriggerEventOnClick : MonoBehaviour
|
|
11
|
+
{
|
|
12
|
+
|
|
13
|
+
[Header("Broadcasting on:")] [SerializeField]
|
|
14
|
+
private TimelineTriggerEventChannelSO TestChannel;
|
|
15
|
+
|
|
16
|
+
[Space(20)]
|
|
17
|
+
[SerializeField] private PlayableAsset timeline;
|
|
18
|
+
[SerializeField] private bool state = true;
|
|
19
|
+
public void CallFunction()
|
|
20
|
+
{
|
|
21
|
+
TestChannel.RaiseEvent(timeline, state);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[CustomEditor(typeof(SendTimelineTriggerEventOnClick))]
|
|
26
|
+
public class SendTimelineTriggerEventOnClickEditor : Editor {
|
|
27
|
+
override public void OnInspectorGUI () {
|
|
28
|
+
DrawDefaultInspector();
|
|
29
|
+
var eventToSend = (SendTimelineTriggerEventOnClick)target;
|
|
30
|
+
if(GUILayout.Button("Send timeline trigger", GUILayout.Height(30))) {
|
|
31
|
+
eventToSend.CallFunction(); // how do i call this?
|
|
32
|
+
}
|
|
33
|
+
GUILayout.Space(10);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#endif
|
|
@@ -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,66 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using UnityEngine.Events;
|
|
3
|
+
using UnityEngine.Playables;
|
|
4
|
+
using UnityEngine.Serialization;
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// To use a generic UnityEvent type you must override the generic type.
|
|
8
|
+
/// </summary>
|
|
9
|
+
namespace jeanf.EventSystem
|
|
10
|
+
{
|
|
11
|
+
[System.Serializable]
|
|
12
|
+
public class TimelineBoolEvent : UnityEvent<PlayableAsset, bool>
|
|
13
|
+
{
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/// <summary>
|
|
18
|
+
/// A flexible handler for int events in the form of a MonoBehaviour. Responses can be connected directly from the Unity Inspector.
|
|
19
|
+
/// </summary>
|
|
20
|
+
public class TimelineTriggerEventListener : MonoBehaviour, IDebugBehaviour
|
|
21
|
+
{
|
|
22
|
+
public bool isDebug
|
|
23
|
+
{
|
|
24
|
+
get => _isDebug;
|
|
25
|
+
set => _isDebug = value;
|
|
26
|
+
}
|
|
27
|
+
[SerializeField] private bool _isDebug = false;
|
|
28
|
+
|
|
29
|
+
[SerializeField] private TimelineTriggerEventChannelSO _channel = default;
|
|
30
|
+
[SerializeField] private PlayableDirector _playableDirectorToControl;
|
|
31
|
+
[Tooltip("Use this if you want to override the timeline assigned to the playable director.")]
|
|
32
|
+
[SerializeField] private bool assignTimelineToPlayableDirector = true;
|
|
33
|
+
[Space(10)]
|
|
34
|
+
|
|
35
|
+
[Tooltip("If you want to do more than just turning triggering play/stop on the timeline")]
|
|
36
|
+
public TimelineBoolEvent OnEventRaised;
|
|
37
|
+
|
|
38
|
+
private void OnEnable()
|
|
39
|
+
{
|
|
40
|
+
if (_channel != null)
|
|
41
|
+
_channel.OnEventRaised += Respond;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private void OnDisable()
|
|
45
|
+
{
|
|
46
|
+
if (_channel != null)
|
|
47
|
+
_channel.OnEventRaised -= Respond;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private void Respond(PlayableAsset timeline, bool value)
|
|
51
|
+
{
|
|
52
|
+
if (assignTimelineToPlayableDirector) _playableDirectorToControl.playableAsset = timeline;
|
|
53
|
+
if(timeline != _playableDirectorToControl.playableAsset) return;
|
|
54
|
+
OnEventRaised?.Invoke(timeline, value);
|
|
55
|
+
if (value)
|
|
56
|
+
{
|
|
57
|
+
_playableDirectorToControl.Play();
|
|
58
|
+
}
|
|
59
|
+
else
|
|
60
|
+
{
|
|
61
|
+
_playableDirectorToControl.Stop();
|
|
62
|
+
}
|
|
63
|
+
if(isDebug) Debug.Log($" timeline-bool event raised: <{timeline},{value}>");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -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,18 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using UnityEngine.Events;
|
|
3
|
+
using UnityEngine.Playables;
|
|
4
|
+
|
|
5
|
+
namespace jeanf.EventSystem
|
|
6
|
+
{
|
|
7
|
+
[CreateAssetMenu(menuName = "Events/Advanced/<Timeline,Bool> Event Channel")]
|
|
8
|
+
|
|
9
|
+
public class TimelineTriggerEventChannelSO : DescriptionBaseSO
|
|
10
|
+
{
|
|
11
|
+
public UnityAction<PlayableAsset, bool> OnEventRaised;
|
|
12
|
+
|
|
13
|
+
public void RaiseEvent(PlayableAsset timeline, bool state)
|
|
14
|
+
{
|
|
15
|
+
OnEventRaised?.Invoke(timeline, state);
|
|
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
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using UnityEngine.Playables;
|
|
3
|
+
|
|
4
|
+
namespace jeanf.EventSystem
|
|
5
|
+
{
|
|
6
|
+
public class TimelineBoolEventSender : MonoBehaviour, IDebugBehaviour
|
|
7
|
+
{
|
|
8
|
+
public bool isDebug
|
|
9
|
+
{
|
|
10
|
+
get => _isDebug;
|
|
11
|
+
set => _isDebug = value;
|
|
12
|
+
}
|
|
13
|
+
[SerializeField] private bool _isDebug = false;
|
|
14
|
+
|
|
15
|
+
[field: Header("Broadcasting on:")] public TimelineTriggerEventChannelSO timelineMessageChannel;
|
|
16
|
+
|
|
17
|
+
public void SendIntBool(PlayableAsset timeline, bool value)
|
|
18
|
+
{
|
|
19
|
+
timelineMessageChannel.RaiseEvent(timeline, value);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
@@ -12,11 +12,11 @@ namespace jeanf.EventSystem
|
|
|
12
12
|
}
|
|
13
13
|
[SerializeField] private bool _isDebug = false;
|
|
14
14
|
[SerializeField] private bool _sendTransfromOnAwake;
|
|
15
|
-
[SerializeField] private bool _sendCustomTransform;
|
|
15
|
+
[SerializeField] private static bool _sendCustomTransform;
|
|
16
16
|
[DrawIf("_sendCustomTransform", true, ComparisonType.Equals)]
|
|
17
17
|
[SerializeField] private Transform _transform;
|
|
18
18
|
|
|
19
|
-
[
|
|
19
|
+
[Header("Broadcasting on:")] public TransformEventChannelSO transformMessageChannel;
|
|
20
20
|
|
|
21
21
|
public void SendTransform(Transform value)
|
|
22
22
|
{
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
%YAML 1.1
|
|
2
|
+
%TAG !u! tag:unity3d.com,2011:
|
|
3
|
+
--- !u!114 &11400000
|
|
4
|
+
MonoBehaviour:
|
|
5
|
+
m_ObjectHideFlags: 0
|
|
6
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
7
|
+
m_PrefabInstance: {fileID: 0}
|
|
8
|
+
m_PrefabAsset: {fileID: 0}
|
|
9
|
+
m_GameObject: {fileID: 0}
|
|
10
|
+
m_Enabled: 1
|
|
11
|
+
m_EditorHideFlags: 0
|
|
12
|
+
m_Script: {fileID: 11500000, guid: 97d0530efe5478143ac4fcef47a977f5, type: 3}
|
|
13
|
+
m_Name: TimelineTriggerChannelSO
|
|
14
|
+
m_EditorClassIdentifier:
|
|
15
|
+
_guid:
|
|
16
|
+
description:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fr.jeanf.eventsystem",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.89",
|
|
4
4
|
"displayName": "Event System",
|
|
5
5
|
"description": "This package contains a basic Event System based on Scriptable Objects as communication medium",
|
|
6
6
|
"unity": "2021.3",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"url": "https://jeanfrancoisrobin.art"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"fr.jeanf.propertydrawer": "1.
|
|
17
|
+
"fr.jeanf.propertydrawer": "1.1.6"
|
|
18
18
|
},
|
|
19
19
|
"samples": [
|
|
20
20
|
{
|
|
File without changes
|