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.
@@ -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,11 @@
1
+ fileFormatVersion: 2
2
+ guid: b7ec5aea555107f41ab4b0c5c779dacf
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,6 +1,4 @@
1
1
  using System;
2
- using System.Collections;
3
- using jeanf.EventSystem;
4
2
  using UnityEngine;
5
3
 
6
4
  namespace jeanf.EventSystem
@@ -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,11 @@
1
+ fileFormatVersion: 2
2
+ guid: ad082b8ba1f184e40b683b8289db4f24
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -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
+
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: f46adcd09ab803f46acaba1ebdc5654f
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name":"fr.jeanf.eventsystem",
3
- "version":"0.1.70",
3
+ "version":"0.1.71",
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",