Skip to content
Snippets Groups Projects
Commit a07b295a authored by Heine, Eric R's avatar Heine, Eric R
Browse files

Added a class that maps Unity Input Actions to Game Events. The shared...

Added a class that maps Unity Input Actions to Game Events.  The shared package is now dependent on the Unity Input system package until it's permanently part of the engine.
parent 7ad50b22
No related branches found
No related tags found
No related merge requests found
fileFormatVersion: 2
guid: 3db7cd7fe135f9d488f16e3a909444a1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
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>());
}
}
}
}
fileFormatVersion: 2
guid: f9df856b7c621e447bec7dd3d5a5c3e9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
{
"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
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment