diff --git a/Scriptable Variables/Senders.meta b/Scriptable Variables/Senders.meta new file mode 100644 index 0000000000000000000000000000000000000000..61f1d54744f6c8c5f1ae52d0a4cc1c3e85a35126 --- /dev/null +++ b/Scriptable Variables/Senders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3db7cd7fe135f9d488f16e3a909444a1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Senders/InputActionToEvent.cs b/Scriptable Variables/Senders/InputActionToEvent.cs new file mode 100644 index 0000000000000000000000000000000000000000..3a87a4b7081da9cae0b06d48ecf171ca97d78d1f --- /dev/null +++ b/Scriptable Variables/Senders/InputActionToEvent.cs @@ -0,0 +1,29 @@ +using UnityEngine; +using UnityEngine.InputSystem; + +namespace Shared.ScriptableVariables { + // Mapper between Unity's new Input action system and the Game Event system + public class InputActionToEvent : MonoBehaviour { + [Tooltip("Event to use for inputs that don't have values associated with them")] + public GameEvent actionFired; + + [Tooltip("Event to use for inputs with values associated with them")] + public FloatGameEvent valueActionFired; + + // -------------------------------------------------------------------------- + public void ActionFired(InputAction.CallbackContext context) { + if (isActiveAndEnabled) { + if (context.performed) { + actionFired?.Raise(); + } + } + } + + // -------------------------------------------------------------------------- + public void ValueActionFired(InputAction.CallbackContext context) { + if (isActiveAndEnabled) { + valueActionFired?.Raise(context.ReadValue<float>()); + } + } + } +} diff --git a/Scriptable Variables/Senders/InputActionToEvent.cs.meta b/Scriptable Variables/Senders/InputActionToEvent.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..c5376044f79a49ffe24af77ab1f6e4cb6b41961a --- /dev/null +++ b/Scriptable Variables/Senders/InputActionToEvent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f9df856b7c621e447bec7dd3d5a5c3e9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scriptable Variables/Shared.ScriptableVariables.asmdef b/Scriptable Variables/Shared.ScriptableVariables.asmdef index ebdf6e7f52867d6fa478e5d3180f3d078a113177..35d7f0abb26c94a0f37ba352ad0ade7aa0ffab27 100644 --- a/Scriptable Variables/Shared.ScriptableVariables.asmdef +++ b/Scriptable Variables/Shared.ScriptableVariables.asmdef @@ -1,12 +1,15 @@ { "name": "Shared.ScriptableVariables", - "references": [], - "optionalUnityReferences": [], + "references": [ + "GUID:75469ad4d38634e559750d17036d5f7c" + ], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, "overrideReferences": false, "precompiledReferences": [], "autoReferenced": true, - "defineConstraints": [] + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false } \ No newline at end of file diff --git a/package.json b/package.json index 8b763718ec33099b865fd0c9236f32467016b70d..8f386ad04157780abc1a10d88d2e95fd26565955 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "com.futuretech.shared", "displayName": "FutureTech Shared", "description": "Contains shared items such as the Scriptable Variables.", - "version": "0.1.22", - "unity": "2019.1", + "version": "0.1.23", + "unity": "2019.2", "license": "MIT", "repository": { "type": "git", @@ -12,5 +12,6 @@ "src": "Assets/FutureTechShared", "author": "mg <mjguerre@nps.edu>", "dependencies": { + "com.unity.inputsystem": "1.0.0-preview.5" } } \ No newline at end of file