fr.jeanf.eventsystem 0.0.1

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.
Files changed (35) hide show
  1. package/.github/workflows/publish.yml +23 -0
  2. package/.github/workflows.meta +8 -0
  3. package/README.md +8 -0
  4. package/README.md.meta +7 -0
  5. package/Runtime/BaseClasses/DescriptionBaseSO.cs +12 -0
  6. package/Runtime/BaseClasses/DescriptionBaseSO.cs.meta +11 -0
  7. package/Runtime/BaseClasses/SerializableScriptableObject.cs +22 -0
  8. package/Runtime/BaseClasses/SerializableScriptableObject.cs.meta +11 -0
  9. package/Runtime/BaseClasses.meta +8 -0
  10. package/Runtime/Listeners/IntEventListener.cs +42 -0
  11. package/Runtime/Listeners/IntEventListener.cs.meta +11 -0
  12. package/Runtime/Listeners/StringEventListener.cs +41 -0
  13. package/Runtime/Listeners/StringEventListener.cs.meta +11 -0
  14. package/Runtime/Listeners/VoidEventListener.cs +33 -0
  15. package/Runtime/Listeners/VoidEventListener.cs.meta +11 -0
  16. package/Runtime/Listeners.meta +8 -0
  17. package/Runtime/ScriptableObjects/IntEventChannelSO.cs +21 -0
  18. package/Runtime/ScriptableObjects/IntEventChannelSO.cs.meta +11 -0
  19. package/Runtime/ScriptableObjects/StringEventChannelSO.cs +20 -0
  20. package/Runtime/ScriptableObjects/StringEventChannelSO.cs.meta +11 -0
  21. package/Runtime/ScriptableObjects/VoidEventChannelSO.cs +17 -0
  22. package/Runtime/ScriptableObjects/VoidEventChannelSO.cs.meta +11 -0
  23. package/Runtime/ScriptableObjects.meta +8 -0
  24. package/Runtime/Senders/EventSender.cs +11 -0
  25. package/Runtime/Senders/EventSender.cs.meta +11 -0
  26. package/Runtime/Senders.meta +8 -0
  27. package/Runtime/jeanf.eventSystem.asmdef +14 -0
  28. package/Runtime/jeanf.eventSystem.asmdef.meta +7 -0
  29. package/Runtime.meta +8 -0
  30. package/Samples/Channels/String Message Channel SO.asset +18 -0
  31. package/Samples/Channels/String Message Channel SO.asset.meta +8 -0
  32. package/Samples/Channels.meta +8 -0
  33. package/Samples.meta +8 -0
  34. package/package.json +25 -0
  35. package/package.json.meta +7 -0
@@ -0,0 +1,23 @@
1
+ name: "🚀 publish"
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ release:
10
+ name: 🚀 publish
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: 📚 checkout
14
+ uses: actions/checkout@v3
15
+ - name: 🟢 node
16
+ uses: actions/setup-node@v3
17
+ with:
18
+ node-version: 16
19
+ registry-url: https://registry.npmjs.org
20
+ - name: 🚀 publish
21
+ run: npm publish --access public
22
+ env:
23
+ NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: da43f397dd3f5be4498216aea829e336
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ This Event System is using scriptable objects as communication medium to avoid code-depedency when using events.
2
+
3
+ In order to find this package in unity's package manager make sure to add the scoped registery to unity's ProjectSettings:
4
+ - click new scopedRegisteries (+) in ProjectSettings/Package manager
5
+ - set the following parameters:
6
+ - name: jeanf
7
+ - url: https://registry.npmjs.com
8
+ - scope fr.jeanf
package/README.md.meta ADDED
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 1cea216c13def8e4a980b13fcf615527
3
+ TextScriptImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,12 @@
1
+ using UnityEngine;
2
+
3
+ namespace jeanf.EventSystem
4
+ {
5
+ /// <summary>
6
+ /// Base class for ScriptableObjects that need a public description field.
7
+ /// </summary>
8
+ public class DescriptionBaseSO : SerializableScriptableObject
9
+ {
10
+ [TextArea] public string description;
11
+ }
12
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 0ffcf2cd9e5ed8041912ce6b98b29b5d
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,22 @@
1
+ using UnityEngine;
2
+
3
+ #if UNITY_EDITOR
4
+ using UnityEditor;
5
+ #endif
6
+
7
+ namespace jeanf.EventSystem
8
+ {
9
+ public class SerializableScriptableObject : ScriptableObject
10
+ {
11
+ [SerializeField, HideInInspector] private string _guid;
12
+ public string Guid => _guid;
13
+
14
+ #if UNITY_EDITOR
15
+ void OnValidate()
16
+ {
17
+ var path = AssetDatabase.GetAssetPath(this);
18
+ _guid = AssetDatabase.AssetPathToGUID(path);
19
+ }
20
+ #endif
21
+ }
22
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: fd1e811ef68fc4b45bd665d2265b4355
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,8 @@
1
+ fileFormatVersion: 2
2
+ guid: e44c811dd8ee80246b3a6d9a78f970eb
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,42 @@
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 IntEvent : UnityEvent<int>
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 IntEventListener : MonoBehaviour
19
+ {
20
+ [SerializeField] private IntEventChannelSO _channel = default;
21
+
22
+ public IntEvent OnEventRaised;
23
+
24
+ private void OnEnable()
25
+ {
26
+ if (_channel != null)
27
+ _channel.OnEventRaised += Respond;
28
+ }
29
+
30
+ private void OnDisable()
31
+ {
32
+ if (_channel != null)
33
+ _channel.OnEventRaised -= Respond;
34
+ }
35
+
36
+ private void Respond(int value)
37
+ {
38
+ if (OnEventRaised != null)
39
+ OnEventRaised.Invoke(value);
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: fd1286d419ad4fe488e14e91d97ed6b9
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,41 @@
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 StringEvent : UnityEvent<string>
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 StringEventListener : MonoBehaviour
19
+ {
20
+ [SerializeField] private StringEventChannelSO _channel = default;
21
+
22
+ public StringEvent OnEventRaised;
23
+
24
+ private void OnEnable()
25
+ {
26
+ if (_channel != null)
27
+ _channel.OnEventRaised += Respond;
28
+ }
29
+
30
+ private void OnDisable()
31
+ {
32
+ if (_channel != null)
33
+ _channel.OnEventRaised -= Respond;
34
+ }
35
+
36
+ private void Respond(string value)
37
+ {
38
+ OnEventRaised?.Invoke(value);
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 9950255415051c04699af99860391358
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,33 @@
1
+ using UnityEngine;
2
+ using UnityEngine.Events;
3
+
4
+ /// <summary>
5
+ /// A flexible handler for void events in the form of a MonoBehaviour. Responses can be connected directly from the Unity Inspector.
6
+ /// </summary>namespace jeanf.EventSystemnamespace jeanf.EventSystem
7
+ namespace jeanf.EventSystem
8
+ {
9
+ public class VoidEventListener : MonoBehaviour
10
+ {
11
+ [SerializeField] private VoidEventChannelSO _channel = default;
12
+
13
+ public UnityEvent OnEventRaised;
14
+
15
+ private void OnEnable()
16
+ {
17
+ if (_channel != null)
18
+ _channel.OnEventRaised += Respond;
19
+ }
20
+
21
+ private void OnDisable()
22
+ {
23
+ if (_channel != null)
24
+ _channel.OnEventRaised -= Respond;
25
+ }
26
+
27
+ private void Respond()
28
+ {
29
+ if (OnEventRaised != null)
30
+ OnEventRaised.Invoke();
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 9de4f9f3fef96bf4e80e2514b4dd7e85
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,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 268ce46fb3fbda440b213270f8c43b62
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -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/Int Event Channel")]
11
+ public class IntEventChannelSO : DescriptionBaseSO
12
+ {
13
+ public UnityAction<int> OnEventRaised;
14
+
15
+ public void RaiseEvent(int value)
16
+ {
17
+ if (OnEventRaised != null)
18
+ OnEventRaised.Invoke(value);
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 915737b55ba9fa344b3172aac9107aea
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,20 @@
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/String Event Channel")]
11
+ public class StringEventChannelSO : DescriptionBaseSO
12
+ {
13
+ public UnityAction<string> OnEventRaised;
14
+
15
+ public void RaiseEvent(string value)
16
+ {
17
+ OnEventRaised?.Invoke(value);
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: b842bdeec62cc754093c6a5120ac1107
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,17 @@
1
+ using UnityEngine;
2
+ using UnityEngine.Events;
3
+
4
+ namespace jeanf.EventSystem
5
+ {
6
+ [CreateAssetMenu(menuName = "Events/Void Event Channel")]
7
+ public class VoidEventChannelSO : DescriptionBaseSO
8
+ {
9
+ public UnityAction OnEventRaised;
10
+
11
+ public void RaiseEvent()
12
+ {
13
+ if (OnEventRaised != null)
14
+ OnEventRaised.Invoke();
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: d84ad29ba75bd634eb5eda8abf406faf
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,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 909af0a5176c6894693913ae66dac3a8
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,11 @@
1
+ using UnityEngine;
2
+ using UnityEngine.Serialization;
3
+
4
+ namespace jeanf.EventSystem
5
+ {
6
+ public class EventSender : MonoBehaviour
7
+ {
8
+ [FormerlySerializedAs("_messageChannel")] [Header("Broadcasting on channels")]
9
+ public StringEventChannelSO _stringMessageChannel;
10
+ }
11
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 870207f5edf6157468e60d341b152e56
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,8 @@
1
+ fileFormatVersion: 2
2
+ guid: bdcbf5f3ac4293845a293dcc5c783001
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "uvs.events",
3
+ "rootNamespace": "",
4
+ "references": [],
5
+ "includePlatforms": [],
6
+ "excludePlatforms": [],
7
+ "allowUnsafeCode": false,
8
+ "overrideReferences": false,
9
+ "precompiledReferences": [],
10
+ "autoReferenced": true,
11
+ "defineConstraints": [],
12
+ "versionDefines": [],
13
+ "noEngineReferences": false
14
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: e134609276952144282613c65d798616
3
+ AssemblyDefinitionImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
package/Runtime.meta ADDED
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: c27b39fa61c42fa44aaeb24493847369
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,18 @@
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: b842bdeec62cc754093c6a5120ac1107, type: 3}
13
+ m_Name: String Message Channel SO
14
+ m_EditorClassIdentifier:
15
+ _guid: a3f2d4caf87f6994092b3187963f8dc3
16
+ description: 'Basic ipad message
17
+
18
+ '
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: a3f2d4caf87f6994092b3187963f8dc3
3
+ NativeFormatImporter:
4
+ externalObjects: {}
5
+ mainObjectFileID: 11400000
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: e1a08db3c25f9f641a1a5b1ed4a5c46c
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
package/Samples.meta ADDED
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 86d7a72a52f0c184cb06aaf1cb1f7b94
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name":"fr.jeanf.eventsystem",
3
+ "version":"0.0.1",
4
+ "displayName":"Event System",
5
+ "description":"This package contains a basic Event System based on Scriptable Objects as communication medium",
6
+ "unity": "2021.3",
7
+ "keywords": [
8
+ "jeanf",
9
+ "event system"
10
+ ],
11
+ "author":{
12
+ "name":"Jean-François Robin",
13
+ "email":"robin.jeanfrancois@gmail.com",
14
+ "url":"https://jeanfrancoisrobin.art"
15
+ },
16
+ "dependencies": {
17
+ },
18
+ "samples": [
19
+ {
20
+ "displayName": "Channels",
21
+ "description": "A set of usefull default channels",
22
+ "path": "Samples/Channels"
23
+ }
24
+ ]
25
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 4ad0ac6c771414245ab6b32cbe64997b
3
+ TextScriptImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant: