浏览代码
Removed InputSystemManager, reworked actions. Start working on base behavior of UIEventManager
/feature-new-input-system
Removed InputSystemManager, reworked actions. Start working on base behavior of UIEventManager
/feature-new-input-system
Thomas ICHÉ
4 年前
当前提交
6d421d01
共有 17 个文件被更改,包括 259 次插入 和 620 次删除
-
99Resources/Default_UIEventManager.prefab
-
8Runtime/LevelScripting/Actions/FocusUIAction.cs
-
10Runtime/LevelScripting/Events/OnInputDirectEvent.cs
-
2Runtime/Managers/Implementations/ScreenshotManager.cs
-
37Runtime/Managers/Implementations/UIEventManager.cs
-
196Runtime/Input/InputSystemUtility.cs
-
20Runtime/LevelScripting/Events/OnInputActionEvent.cs
-
11Editor/PropertyDrawers/RegisteredInputActionsPropertyDrawer.cs.meta
-
167Editor/PropertyDrawers/RegisteredInputActionsPropertyDrawer.cs
-
46Resources/Default_InputSystemManager.prefab
-
7Resources/Default_InputSystemManager.prefab.meta
-
256Runtime/Input/InputSystemManager.cs
-
20Runtime/LevelScripting/Events/OnInputEvent.cs
-
0/Runtime/Input/InputSystemUtility.cs.meta
-
0/Runtime/LevelScripting/Events/OnInputDirectEvent.cs.meta
-
0/Runtime/LevelScripting/Events/OnInputActionEvent.cs.meta
-
0/Runtime/LevelScripting/Events/OnInputDirectEvent.cs
|
|||
using System; |
|||
using UnityEngine; |
|||
#if ENABLE_INPUT_SYSTEM
|
|||
using UnityEngine.InputSystem; |
|||
using UnityEngine.InputSystem.Controls; |
|||
|
|||
namespace GameplayIngredients |
|||
{ |
|||
public static class InputSystemUtility |
|||
{ |
|||
public static ButtonControl GetButton(MouseButton b) |
|||
{ |
|||
Mouse m = Mouse.current; |
|||
switch (b) |
|||
{ |
|||
case MouseButton.Left: return m.leftButton; |
|||
case MouseButton.Right: return m.rightButton; |
|||
case MouseButton.Middle: return m.middleButton; |
|||
case MouseButton.Back: return m.backButton; |
|||
case MouseButton.Forward: return m.forwardButton; |
|||
default: |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
} |
|||
public static ButtonControl GetButton(GamepadButton b) |
|||
{ |
|||
Gamepad p = Gamepad.current; |
|||
switch (b) |
|||
{ |
|||
case GamepadButton.A: return p.aButton; |
|||
case GamepadButton.B: return p.bButton; |
|||
case GamepadButton.X: return p.xButton; |
|||
case GamepadButton.Y: return p.yButton; |
|||
case GamepadButton.LeftShoulder: return p.leftShoulder; |
|||
case GamepadButton.LeftTrigger: return p.leftTrigger; |
|||
case GamepadButton.RightShoulder: return p.rightShoulder; |
|||
case GamepadButton.RightTrigger: return p.rightTrigger; |
|||
case GamepadButton.LeftThumbStick: return p.leftStickButton; |
|||
case GamepadButton.RightThumbStick: return p.rightStickButton; |
|||
case GamepadButton.Start: return p.startButton; |
|||
case GamepadButton.Select: return p.selectButton; |
|||
default: |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
} |
|||
public static ButtonControl GetButton(Key k) |
|||
{ |
|||
Keyboard kb = Keyboard.current; |
|||
switch (k) |
|||
{ |
|||
case Key.Space: return kb.spaceKey; |
|||
case Key.Enter: return kb.enterKey; |
|||
case Key.Tab: return kb.tabKey; |
|||
case Key.Backquote: return kb.backquoteKey; |
|||
case Key.Quote: return kb.quoteKey; |
|||
case Key.Semicolon: return kb.semicolonKey; |
|||
case Key.Comma: return kb.commaKey; |
|||
case Key.Period: return kb.periodKey; |
|||
case Key.Slash: return kb.slashKey; |
|||
case Key.Backslash: return kb.backslashKey; |
|||
case Key.LeftBracket: return kb.leftBracketKey; |
|||
case Key.RightBracket: return kb.rightBracketKey; |
|||
case Key.Minus: return kb.minusKey; |
|||
case Key.Equals: return kb.equalsKey; |
|||
case Key.A: return kb.aKey; |
|||
case Key.B: return kb.bKey; |
|||
case Key.C: return kb.cKey; |
|||
case Key.D: return kb.dKey; |
|||
case Key.E: return kb.eKey; |
|||
case Key.F: return kb.fKey; |
|||
case Key.G: return kb.gKey; |
|||
case Key.H: return kb.hKey; |
|||
case Key.I: return kb.iKey; |
|||
case Key.J: return kb.jKey; |
|||
case Key.K: return kb.kKey; |
|||
case Key.L: return kb.lKey; |
|||
case Key.M: return kb.mKey; |
|||
case Key.N: return kb.nKey; |
|||
case Key.O: return kb.oKey; |
|||
case Key.P: return kb.pKey; |
|||
case Key.Q: return kb.qKey; |
|||
case Key.R: return kb.rKey; |
|||
case Key.S: return kb.sKey; |
|||
case Key.T: return kb.tKey; |
|||
case Key.U: return kb.uKey; |
|||
case Key.V: return kb.vKey; |
|||
case Key.W: return kb.wKey; |
|||
case Key.X: return kb.xKey; |
|||
case Key.Y: return kb.yKey; |
|||
case Key.Z: return kb.zKey; |
|||
case Key.Digit1: return kb.digit1Key; |
|||
case Key.Digit2: return kb.digit2Key; |
|||
case Key.Digit3: return kb.digit3Key; |
|||
case Key.Digit4: return kb.digit4Key; |
|||
case Key.Digit5: return kb.digit5Key; |
|||
case Key.Digit6: return kb.digit6Key; |
|||
case Key.Digit7: return kb.digit7Key; |
|||
case Key.Digit8: return kb.digit8Key; |
|||
case Key.Digit9: return kb.digit9Key; |
|||
case Key.Digit0: return kb.digit0Key; |
|||
case Key.LeftShift: return kb.leftShiftKey; |
|||
case Key.RightShift: return kb.rightShiftKey; |
|||
case Key.LeftAlt: return kb.leftAltKey; |
|||
case Key.RightAlt: return kb.rightAltKey; |
|||
case Key.LeftCtrl: return kb.leftCtrlKey; |
|||
case Key.RightCtrl: return kb.rightCtrlKey; |
|||
case Key.LeftMeta: return kb.leftMetaKey; |
|||
case Key.RightMeta: return kb.rightMetaKey; |
|||
case Key.ContextMenu: return kb.contextMenuKey; |
|||
case Key.Escape: return kb.escapeKey; |
|||
case Key.LeftArrow: return kb.leftArrowKey; |
|||
case Key.RightArrow: return kb.rightArrowKey; |
|||
case Key.UpArrow: return kb.upArrowKey; |
|||
case Key.DownArrow: return kb.downArrowKey; |
|||
case Key.Backspace: return kb.backspaceKey; |
|||
case Key.PageDown: return kb.pageDownKey; |
|||
case Key.PageUp: return kb.pageUpKey; |
|||
case Key.Home: return kb.homeKey; |
|||
case Key.End: return kb.endKey; |
|||
case Key.Insert: return kb.insertKey; |
|||
case Key.Delete: return kb.deleteKey; |
|||
case Key.CapsLock: return kb.capsLockKey; |
|||
case Key.NumLock: return kb.numLockKey; |
|||
case Key.PrintScreen: return kb.printScreenKey; |
|||
case Key.ScrollLock: return kb.scrollLockKey; |
|||
case Key.Pause: return kb.pauseKey; |
|||
case Key.NumpadEnter: return kb.numpadEnterKey; |
|||
case Key.NumpadDivide: return kb.numpadDivideKey; |
|||
case Key.NumpadMultiply: return kb.numpadMultiplyKey; |
|||
case Key.NumpadPlus: return kb.numpadPlusKey; |
|||
case Key.NumpadMinus: return kb.numpadMinusKey; |
|||
case Key.NumpadPeriod: return kb.numpadPeriodKey; |
|||
case Key.NumpadEquals: return kb.equalsKey; |
|||
case Key.Numpad0: return kb.numpad0Key; |
|||
case Key.Numpad1: return kb.numpad1Key; |
|||
case Key.Numpad2: return kb.numpad2Key; |
|||
case Key.Numpad3: return kb.numpad3Key; |
|||
case Key.Numpad4: return kb.numpad4Key; |
|||
case Key.Numpad5: return kb.numpad5Key; |
|||
case Key.Numpad6: return kb.numpad6Key; |
|||
case Key.Numpad7: return kb.numpad7Key; |
|||
case Key.Numpad8: return kb.numpad8Key; |
|||
case Key.Numpad9: return kb.numpad9Key; |
|||
case Key.F1: return kb.f1Key; |
|||
case Key.F2: return kb.f2Key; |
|||
case Key.F3: return kb.f3Key; |
|||
case Key.F4: return kb.f4Key; |
|||
case Key.F5: return kb.f5Key; |
|||
case Key.F6: return kb.f6Key; |
|||
case Key.F7: return kb.f7Key; |
|||
case Key.F8: return kb.f8Key; |
|||
case Key.F9: return kb.f9Key; |
|||
case Key.F10: return kb.f10Key; |
|||
case Key.F11: return kb.f11Key; |
|||
case Key.F12: return kb.f12Key; |
|||
case Key.OEM1: return kb.oem1Key; |
|||
case Key.OEM2: return kb.oem2Key; |
|||
case Key.OEM3: return kb.oem3Key; |
|||
case Key.OEM4: return kb.oem4Key; |
|||
case Key.OEM5: return kb.oem5Key; |
|||
case Key.IMESelected: return kb.imeSelected; |
|||
default: |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
} |
|||
|
|||
#endif
|
|||
} |
|||
|
|||
public enum Device |
|||
{ |
|||
Gamepad, |
|||
Keyboard, |
|||
Mouse |
|||
} |
|||
|
|||
public enum MouseButton |
|||
{ |
|||
Left, |
|||
Right, |
|||
Middle, |
|||
Back, |
|||
Forward |
|||
} |
|||
|
|||
public enum GamepadButton |
|||
{ |
|||
A, B, X, Y, |
|||
LeftShoulder, LeftTrigger, RightShoulder, RightTrigger, |
|||
LeftThumbStick, RightThumbStick, |
|||
Start, Select, |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|
|||
using UnityEngine; |
|||
#if ENABLE_INPUT_SYSTEM
|
|||
using UnityEngine.InputSystem; |
|||
#endif
|
|||
|
|||
namespace GameplayIngredients.Events |
|||
{ |
|||
#if !ENABLE_INPUT_SYSTEM
|
|||
[WarnDisabledModule("New Input System")] |
|||
#endif
|
|||
[AddComponentMenu(ComponentMenu.eventsPath + "On Input Action Event (New Input System)")] |
|||
public class OnInputActionEvent : EventBase |
|||
{ |
|||
#if ENABLE_INPUT_SYSTEM
|
|||
public InputAction inputAction; |
|||
#endif
|
|||
} |
|||
} |
|||
|
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: c8ac85428885ec74f9a693cbb82c9f92 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using GameplayIngredients.Managers; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using UnityEditor; |
|||
using UnityEngine; |
|||
using UnityEngine.InputSystem; |
|||
|
|||
namespace GameplayIngredients.Editor |
|||
{ |
|||
[CustomPropertyDrawer(typeof(InputSystemManager.RegisteredInputAction))] |
|||
public class RegisteredInputActionsPropertyDrawer : PropertyDrawer |
|||
{ |
|||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) |
|||
{ |
|||
if (GameplayIngredientsSettings.currentSettings.excludedeManagers.Contains(nameof(InputSystemManager))) |
|||
return EditorGUIUtility.singleLineHeight * 2.5f; |
|||
else |
|||
{ |
|||
return 2 * base.GetPropertyHeight(property, label); |
|||
} |
|||
} |
|||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) |
|||
{ |
|||
#if ENABLE_INPUT_SYSTEM
|
|||
if (GameplayIngredientsSettings.currentSettings.excludedeManagers.Contains(typeof(InputSystemManager).Name)) |
|||
{ |
|||
EditorGUI.HelpBox(position, "Cannot check for Input Actions : \nInputSystemManager is excluded in your Assets/Resources/GameplayIngredientsSettings.asset", MessageType.Error); |
|||
return; |
|||
} |
|||
InputSystemManager ism = GetDefaultInputSystemManager(); |
|||
if(ism == null) |
|||
{ |
|||
GUI.color = Color.red; |
|||
EditorGUI.LabelField(position,"Error while getting the InputSystemManager prefab", EditorStyles.boldLabel); |
|||
GUI.color = Color.white; |
|||
return; |
|||
} |
|||
|
|||
position.height = EditorGUIUtility.singleLineHeight; |
|||
|
|||
int length = 1 + ism.inputActions.Length; |
|||
GUIContent[] displayedOptions = new GUIContent[length]; |
|||
int[] optionValues = new int[length]; |
|||
for(int i = 0; i<length; i++) |
|||
{ |
|||
if (i == 0) |
|||
displayedOptions[i] = Contents.noPreset; |
|||
else |
|||
{ |
|||
var action = ism.inputActions[i - 1].inputActionAsset; |
|||
|
|||
displayedOptions[i] = action? new GUIContent(action.name) : Contents.nullEntry ; |
|||
} |
|||
optionValues[i] = i - 1; |
|||
} |
|||
|
|||
int value = -1; |
|||
|
|||
if(ism.inputActions.Any(o => o.inputActionAsset == GetInputAsset(property) )) |
|||
{ |
|||
for(int i = 0; i < ism.inputActions.Length; i++) |
|||
{ |
|||
if (ism.inputActions[i].inputActionAsset != null && ism.inputActions[i].inputActionAsset == property.FindPropertyRelative("asset").objectReferenceValue) |
|||
{ |
|||
value = i; |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
value = EditorGUI.IntPopup(position, Contents.preset, value, displayedOptions, optionValues); |
|||
|
|||
if(GUI.changed) |
|||
{ |
|||
if (value == -1) |
|||
property.FindPropertyRelative("asset").objectReferenceValue = null; |
|||
else |
|||
property.FindPropertyRelative("asset").objectReferenceValue = ism.inputActions[value].inputActionAsset; |
|||
} |
|||
|
|||
position.yMin += EditorGUIUtility.singleLineHeight; |
|||
position.height = EditorGUIUtility.singleLineHeight; |
|||
|
|||
if (GetInputAsset(property) != null) |
|||
{ |
|||
InputActionAsset ia = property.FindPropertyRelative("asset").objectReferenceValue as InputActionAsset; |
|||
List<string> items = new List<string>(); |
|||
|
|||
foreach(var actionMap in ia.actionMaps) |
|||
{ |
|||
foreach(var action in actionMap.actions) |
|||
{ |
|||
items.Add($"{actionMap.name}/{action.name}"); |
|||
} |
|||
} |
|||
|
|||
string val = property.FindPropertyRelative("actionPath").stringValue; |
|||
int selected = -1; |
|||
GUIContent[] names = new GUIContent[items.Count]; |
|||
int[] indices = new int[items.Count]; |
|||
for(int i = 0; i < items.Count; i++) |
|||
{ |
|||
names[i] = new GUIContent(items[i]); |
|||
indices[i] = i; |
|||
|
|||
if (val == items[i]) |
|||
selected = i; |
|||
} |
|||
|
|||
selected = EditorGUI.IntPopup(position, new GUIContent(" - Action"), selected, names, indices); |
|||
|
|||
if(GUI.changed) |
|||
{ |
|||
property.FindPropertyRelative("actionPath").stringValue = items[selected]; |
|||
} |
|||
|
|||
} |
|||
#else
|
|||
EditorGUI.HelpBox(position, "New Input System package is not installed", MessageType.Warning); |
|||
#endif
|
|||
} |
|||
|
|||
static InputAction GetAction(SerializedProperty property) |
|||
{ |
|||
var inputAsset = GetInputAsset(property); |
|||
string path = property.FindPropertyRelative("actionPath").stringValue; |
|||
return InputSystemManager.RegisteredInputAction.GetAtPath(inputAsset, path); |
|||
} |
|||
|
|||
static InputActionAsset GetInputAsset(SerializedProperty property) |
|||
{ |
|||
return property.FindPropertyRelative("asset").objectReferenceValue as InputActionAsset; |
|||
} |
|||
|
|||
InputSystemManager GetDefaultInputSystemManager() |
|||
{ |
|||
string prefabName = typeof(InputSystemManager).GetCustomAttribute<ManagerDefaultPrefabAttribute>().prefab; |
|||
|
|||
GameObject prefab = Resources.Load<GameObject>(prefabName); |
|||
|
|||
if(prefab != null && prefab.TryGetComponent(out InputSystemManager ism)) |
|||
{ |
|||
return ism; |
|||
} |
|||
|
|||
prefab = Resources.Load<GameObject>("Default_" + prefabName); |
|||
if (prefab != null && prefab.TryGetComponent(out InputSystemManager ism2)) |
|||
{ |
|||
return ism2; |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
static class Contents |
|||
{ |
|||
public static GUIContent preset = new GUIContent("Preset", "Preset as defined in your InputSystemManager"); |
|||
public static GUIContent noPreset = new GUIContent("(No Preset)"); |
|||
public static GUIContent nullEntry = new GUIContent("Null Entry defined in InputSystemManager"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &9173868411675018652 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 1529753585102584546} |
|||
- component: {fileID: -2206566852769537897} |
|||
m_Layer: 0 |
|||
m_Name: Default_InputSystemManager |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &1529753585102584546 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 9173868411675018652} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 0, y: 0, z: 0} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_Children: [] |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!114 &-2206566852769537897 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 9173868411675018652} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 44bbe53f07c77d14da3555d7d06ba904, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_InputActions: [] |
|
|||
fileFormatVersion: 2 |
|||
guid: 63a0d71fc5ba40644b03c49f0e64a0a9 |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEngine; |
|||
#if ENABLE_INPUT_SYSTEM
|
|||
using UnityEngine.InputSystem; |
|||
using UnityEngine.InputSystem.Controls; |
|||
#endif
|
|||
|
|||
namespace GameplayIngredients.Managers |
|||
{ |
|||
#if !ENABLE_INPUT_SYSTEM
|
|||
[DoNotCreateManager] |
|||
[WarnDisabledModule("New Input System","Player Settings")] |
|||
#endif
|
|||
[AddComponentMenu(ComponentMenu.managersPath + "Input System Manager (New Input System)")] |
|||
[ManagerDefaultPrefab("InputSystemManager")] |
|||
public class InputSystemManager : Manager |
|||
{ |
|||
|
|||
#if ENABLE_INPUT_SYSTEM
|
|||
public InputActionDefinition[] inputActions { get => m_InputActions; } |
|||
|
|||
[SerializeField] |
|||
InputActionDefinition[] m_InputActions; |
|||
|
|||
[Serializable] |
|||
public struct InputActionDefinition |
|||
{ |
|||
public InputActionAsset inputActionAsset; |
|||
public bool createUIActions; |
|||
|
|||
} |
|||
|
|||
public static ButtonControl GetButton(MouseButton b) |
|||
{ |
|||
Mouse m = Mouse.current; |
|||
switch (b) |
|||
{ |
|||
case MouseButton.Left: return m.leftButton; |
|||
case MouseButton.Right: return m.rightButton; |
|||
case MouseButton.Middle: return m.middleButton; |
|||
case MouseButton.Back: return m.backButton; |
|||
case MouseButton.Forward: return m.forwardButton; |
|||
default: |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
} |
|||
public static ButtonControl GetButton(GamepadButton b) |
|||
{ |
|||
Gamepad p = Gamepad.current; |
|||
switch (b) |
|||
{ |
|||
case GamepadButton.A: return p.aButton; |
|||
case GamepadButton.B: return p.bButton; |
|||
case GamepadButton.X: return p.xButton; |
|||
case GamepadButton.Y: return p.yButton; |
|||
case GamepadButton.LeftShoulder: return p.leftShoulder; |
|||
case GamepadButton.LeftTrigger: return p.leftTrigger; |
|||
case GamepadButton.RightShoulder: return p.rightShoulder; |
|||
case GamepadButton.RightTrigger: return p.rightTrigger; |
|||
case GamepadButton.LeftThumbStick: return p.leftStickButton; |
|||
case GamepadButton.RightThumbStick: return p.rightStickButton; |
|||
case GamepadButton.Start: return p.startButton; |
|||
case GamepadButton.Select: return p.selectButton; |
|||
default: |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
} |
|||
|
|||
public static ButtonControl GetButton(Key k) |
|||
{ |
|||
Keyboard kb = Keyboard.current; |
|||
switch (k) |
|||
{ |
|||
case Key.Space: return kb.spaceKey; |
|||
case Key.Enter: return kb.enterKey; |
|||
case Key.Tab: return kb.tabKey; |
|||
case Key.Backquote: return kb.backquoteKey; |
|||
case Key.Quote: return kb.quoteKey; |
|||
case Key.Semicolon: return kb.semicolonKey; |
|||
case Key.Comma: return kb.commaKey; |
|||
case Key.Period: return kb.periodKey; |
|||
case Key.Slash: return kb.slashKey; |
|||
case Key.Backslash: return kb.backslashKey; |
|||
case Key.LeftBracket: return kb.leftBracketKey; |
|||
case Key.RightBracket: return kb.rightBracketKey; |
|||
case Key.Minus: return kb.minusKey; |
|||
case Key.Equals: return kb.equalsKey; |
|||
case Key.A: return kb.aKey; |
|||
case Key.B: return kb.bKey; |
|||
case Key.C: return kb.cKey; |
|||
case Key.D: return kb.dKey; |
|||
case Key.E: return kb.eKey; |
|||
case Key.F: return kb.fKey; |
|||
case Key.G: return kb.gKey; |
|||
case Key.H: return kb.hKey; |
|||
case Key.I: return kb.iKey; |
|||
case Key.J: return kb.jKey; |
|||
case Key.K: return kb.kKey; |
|||
case Key.L: return kb.lKey; |
|||
case Key.M: return kb.mKey; |
|||
case Key.N: return kb.nKey; |
|||
case Key.O: return kb.oKey; |
|||
case Key.P: return kb.pKey; |
|||
case Key.Q: return kb.qKey; |
|||
case Key.R: return kb.rKey; |
|||
case Key.S: return kb.sKey; |
|||
case Key.T: return kb.tKey; |
|||
case Key.U: return kb.uKey; |
|||
case Key.V: return kb.vKey; |
|||
case Key.W: return kb.wKey; |
|||
case Key.X: return kb.xKey; |
|||
case Key.Y: return kb.yKey; |
|||
case Key.Z: return kb.zKey; |
|||
case Key.Digit1: return kb.digit1Key; |
|||
case Key.Digit2: return kb.digit2Key; |
|||
case Key.Digit3: return kb.digit3Key; |
|||
case Key.Digit4: return kb.digit4Key; |
|||
case Key.Digit5: return kb.digit5Key; |
|||
case Key.Digit6: return kb.digit6Key; |
|||
case Key.Digit7: return kb.digit7Key; |
|||
case Key.Digit8: return kb.digit8Key; |
|||
case Key.Digit9: return kb.digit9Key; |
|||
case Key.Digit0: return kb.digit0Key; |
|||
case Key.LeftShift: return kb.leftShiftKey; |
|||
case Key.RightShift: return kb.rightShiftKey; |
|||
case Key.LeftAlt: return kb.leftAltKey; |
|||
case Key.RightAlt: return kb.rightAltKey; |
|||
case Key.LeftCtrl: return kb.leftCtrlKey; |
|||
case Key.RightCtrl: return kb.rightCtrlKey; |
|||
case Key.LeftMeta: return kb.leftMetaKey; |
|||
case Key.RightMeta: return kb.rightMetaKey; |
|||
case Key.ContextMenu: return kb.contextMenuKey; |
|||
case Key.Escape: return kb.escapeKey; |
|||
case Key.LeftArrow: return kb.leftArrowKey; |
|||
case Key.RightArrow: return kb.rightArrowKey; |
|||
case Key.UpArrow: return kb.upArrowKey; |
|||
case Key.DownArrow: return kb.downArrowKey; |
|||
case Key.Backspace: return kb.backspaceKey; |
|||
case Key.PageDown: return kb.pageDownKey; |
|||
case Key.PageUp: return kb.pageUpKey; |
|||
case Key.Home: return kb.homeKey; |
|||
case Key.End: return kb.endKey; |
|||
case Key.Insert: return kb.insertKey; |
|||
case Key.Delete: return kb.deleteKey; |
|||
case Key.CapsLock: return kb.capsLockKey; |
|||
case Key.NumLock: return kb.numLockKey; |
|||
case Key.PrintScreen: return kb.printScreenKey; |
|||
case Key.ScrollLock: return kb.scrollLockKey; |
|||
case Key.Pause: return kb.pauseKey; |
|||
case Key.NumpadEnter: return kb.numpadEnterKey; |
|||
case Key.NumpadDivide: return kb.numpadDivideKey; |
|||
case Key.NumpadMultiply: return kb.numpadMultiplyKey; |
|||
case Key.NumpadPlus: return kb.numpadPlusKey; |
|||
case Key.NumpadMinus: return kb.numpadMinusKey; |
|||
case Key.NumpadPeriod: return kb.numpadPeriodKey; |
|||
case Key.NumpadEquals: return kb.equalsKey; |
|||
case Key.Numpad0: return kb.numpad0Key; |
|||
case Key.Numpad1: return kb.numpad1Key; |
|||
case Key.Numpad2: return kb.numpad2Key; |
|||
case Key.Numpad3: return kb.numpad3Key; |
|||
case Key.Numpad4: return kb.numpad4Key; |
|||
case Key.Numpad5: return kb.numpad5Key; |
|||
case Key.Numpad6: return kb.numpad6Key; |
|||
case Key.Numpad7: return kb.numpad7Key; |
|||
case Key.Numpad8: return kb.numpad8Key; |
|||
case Key.Numpad9: return kb.numpad9Key; |
|||
case Key.F1: return kb.f1Key; |
|||
case Key.F2: return kb.f2Key; |
|||
case Key.F3: return kb.f3Key; |
|||
case Key.F4: return kb.f4Key; |
|||
case Key.F5: return kb.f5Key; |
|||
case Key.F6: return kb.f6Key; |
|||
case Key.F7: return kb.f7Key; |
|||
case Key.F8: return kb.f8Key; |
|||
case Key.F9: return kb.f9Key; |
|||
case Key.F10: return kb.f10Key; |
|||
case Key.F11: return kb.f11Key; |
|||
case Key.F12: return kb.f12Key; |
|||
case Key.OEM1: return kb.oem1Key; |
|||
case Key.OEM2: return kb.oem2Key; |
|||
case Key.OEM3: return kb.oem3Key; |
|||
case Key.OEM4: return kb.oem4Key; |
|||
case Key.OEM5: return kb.oem5Key; |
|||
case Key.IMESelected: return kb.imeSelected; |
|||
default: |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
} |
|||
[System.Serializable] |
|||
public struct RegisteredInputAction |
|||
{ |
|||
public InputActionAsset asset; |
|||
public string actionPath; |
|||
|
|||
public InputAction action => GetAtPath(this.asset, this.actionPath); |
|||
|
|||
public static InputAction GetAtPath(InputActionAsset asset, string path) |
|||
{ |
|||
if (asset == null) |
|||
return null; |
|||
|
|||
if (string.IsNullOrEmpty(path)) |
|||
return null; |
|||
|
|||
string[] split = path.Split('/'); |
|||
|
|||
foreach(var map in asset.actionMaps) |
|||
{ |
|||
if (!map.name.Equals(split[0])) |
|||
continue; |
|||
|
|||
foreach(var action in map.actions) |
|||
{ |
|||
if (action.name.Equals(split[1])) |
|||
return action; |
|||
} |
|||
} |
|||
return null; |
|||
|
|||
} |
|||
} |
|||
|
|||
#endif
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public enum Device |
|||
{ |
|||
Gamepad, |
|||
Keyboard, |
|||
Mouse |
|||
} |
|||
|
|||
public enum MouseButton |
|||
{ |
|||
Left, |
|||
Right, |
|||
Middle, |
|||
Back, |
|||
Forward |
|||
} |
|||
|
|||
public enum GamepadButton |
|||
{ |
|||
A, B, X, Y, |
|||
LeftShoulder, LeftTrigger, RightShoulder, RightTrigger, |
|||
LeftThumbStick, RightThumbStick, |
|||
Start, Select, |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|
|||
using UnityEngine; |
|||
#if ENABLE_INPUT_SYSTEM
|
|||
using GameplayIngredients.Managers; |
|||
#endif
|
|||
|
|||
namespace GameplayIngredients.Events |
|||
{ |
|||
#if !ENABLE_INPUT_SYSTEM
|
|||
[WarnDisabledModule("New Input System")] |
|||
#endif
|
|||
[AddComponentMenu(ComponentMenu.eventsPath + "On Input Event (New Input System)")] |
|||
public class OnInputEvent : EventBase |
|||
{ |
|||
#if ENABLE_INPUT_SYSTEM
|
|||
public InputSystemManager.RegisteredInputAction inputAction; |
|||
#endif
|
|||
} |
|||
} |
|||
|
|||
|
撰写
预览
正在加载...
取消
保存
Reference in new issue