浏览代码

Removed InputSystemManager, reworked actions. Start working on base behavior of UIEventManager

/feature-new-input-system
Thomas ICHÉ 3 年前
当前提交
6d421d01
共有 17 个文件被更改,包括 259 次插入620 次删除
  1. 99
      Resources/Default_UIEventManager.prefab
  2. 8
      Runtime/LevelScripting/Actions/FocusUIAction.cs
  3. 10
      Runtime/LevelScripting/Events/OnInputDirectEvent.cs
  4. 2
      Runtime/Managers/Implementations/ScreenshotManager.cs
  5. 37
      Runtime/Managers/Implementations/UIEventManager.cs
  6. 196
      Runtime/Input/InputSystemUtility.cs
  7. 20
      Runtime/LevelScripting/Events/OnInputActionEvent.cs
  8. 11
      Editor/PropertyDrawers/RegisteredInputActionsPropertyDrawer.cs.meta
  9. 167
      Editor/PropertyDrawers/RegisteredInputActionsPropertyDrawer.cs
  10. 46
      Resources/Default_InputSystemManager.prefab
  11. 7
      Resources/Default_InputSystemManager.prefab.meta
  12. 256
      Runtime/Input/InputSystemManager.cs
  13. 20
      Runtime/LevelScripting/Events/OnInputEvent.cs
  14. 0
      /Runtime/Input/InputSystemUtility.cs.meta
  15. 0
      /Runtime/LevelScripting/Events/OnInputDirectEvent.cs.meta
  16. 0
      /Runtime/LevelScripting/Events/OnInputActionEvent.cs.meta
  17. 0
      /Runtime/LevelScripting/Events/OnInputDirectEvent.cs

99
Resources/Default_UIEventManager.prefab


- component: {fileID: 6448262098318784312}
- component: {fileID: 6448262098318784313}
- component: {fileID: 6448262098318784318}
- component: {fileID: 3503333848817670599}
- component: {fileID: 1487830702371190246}
- component: {fileID: 3510890780544069616}
- component: {fileID: 9185997359459746325}
- component: {fileID: 9014956111711983296}
m_Layer: 0
m_Name: Default_UIEventManager
m_TagString: Untagged

m_Name:
m_EditorClassIdentifier:
m_EventSystem: {fileID: 6448262098318784313}
--- !u!114 &3503333848817670599
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6448262098318784316}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 718c1945292acbd4497cd28bcaa94f8d, type: 3}
m_Name:
m_EditorClassIdentifier:
OnStart:
- {fileID: 1487830702371190246}
--- !u!114 &1487830702371190246
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6448262098318784316}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a579c054a1017f84e9e093fad80ad6cb, type: 3}
m_Name:
m_EditorClassIdentifier:
Name: Check Input Logic
OnLegacyInputPresent:
- {fileID: 3510890780544069616}
OnLegacyInputNotPresent: []
OnNewInputPresent:
- {fileID: 9185997359459746325}
OnNewInputNotPresent: []
--- !u!114 &3510890780544069616
--- !u!114 &6448262098318784319
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 756d008da58a19e4dbc02fa1e3c84852, type: 3}
m_Name:
m_EditorClassIdentifier:
Name: 'Enable Legacy Standalone Input '
Targets:
- Behaviour: {fileID: 6448262098318784319}
State: 1
--- !u!114 &6448262098318784319
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6448262098318784316}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:

m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 1
--- !u!114 &9185997359459746325
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6448262098318784316}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 756d008da58a19e4dbc02fa1e3c84852, type: 3}
m_Name:
m_EditorClassIdentifier:
Name: 'Enable New Standalone Input '
Targets:
- Behaviour: {fileID: 9014956111711983296}
State: 1
--- !u!114 &9014956111711983296
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6448262098318784316}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
m_Name:
m_EditorClassIdentifier:
m_MoveRepeatDelay: 0.5
m_MoveRepeatRate: 0.1
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_PointAction: {fileID: 1054132383583890850, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_MoveAction: {fileID: 3710738434707379630, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_SubmitAction: {fileID: 2064916234097673511, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_CancelAction: {fileID: -1967631576421560919, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_LeftClickAction: {fileID: 8056856818456041789, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_MiddleClickAction: {fileID: 3279352641294131588, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_RightClickAction: {fileID: 3837173908680883260, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_ScrollWheelAction: {fileID: 4502412055082496612, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_TrackedDevicePositionAction: {fileID: 4754684134866288074, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_TrackedDeviceOrientationAction: {fileID: 1025543830046995696, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_DeselectOnBackgroundClick: 1
m_PointerBehavior: 0

8
Runtime/LevelScripting/Actions/FocusUIAction.cs


public override void Execute(GameObject instigator = null)
{
if (UIObjectToFocus != null)
{
// Workaround : Before selecting, we ensure that there's no selection in the EventSystem
Manager.Get<UIEventManager>().eventSystem.SetSelectedGameObject(null);
UIObjectToFocus.Select();
}
Manager.Get<UIEventManager>().FocusUI(UIObjectToFocus);
public override string GetDefaultName()
{
return $"Focus UI : '{UIObjectToFocus?.name}'";

10
Runtime/LevelScripting/Events/OnInputDirectEvent.cs


#if !ENABLE_INPUT_SYSTEM
[WarnDisabledModule("New Input System")]
#endif
[AddComponentMenu(ComponentMenu.eventsPath + "On Direct Input Event (New Input System)")]
public class OnDirectInputEvent : EventBase
[AddComponentMenu(ComponentMenu.eventsPath + "On Input Direct Event (New Input System)")]
public class OnInputDirectEvent : EventBase
{
[SerializeField]
Device device = Device.Keyboard;

switch (d)
{
case Device.Gamepad:
return InputSystemManager.GetButton(gamepadButton);
return InputSystemUtility.GetButton(gamepadButton);
return InputSystemManager.GetButton(keyboardKey);
return InputSystemUtility.GetButton(keyboardKey);
return InputSystemManager.GetButton(mouseButton);
return InputSystemUtility.GetButton(mouseButton);
default:
throw new System.NotImplementedException();
}

2
Runtime/Managers/Implementations/ScreenshotManager.cs


#if ENABLE_LEGACY_INPUT_MANAGER
if (Input.GetKeyDown(ScreenshotKeyCode))
#elif ENABLE_INPUT_SYSTEM
if (InputSystemManager.GetButton(ScreenshotKey).wasPressedThisFrame)
if (InputSystemUtility.GetButton(ScreenshotKey).wasPressedThisFrame)
#else
if(false)
#endif

37
Runtime/Managers/Implementations/UIEventManager.cs


using NaughtyAttributes;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.UI;
using UnityEngine.UI;
#endif
#if ENABLE_LEGACY_INPUT_MANAGER
#endif
#if ENABLE_INPUT_SYSTEM
[RequireComponent(typeof(InputSystemUIInputModule))]
#endif
public EventSystem eventSystem { get { return m_EventSystem; } }
[SerializeField]
private EventSystem m_EventSystem;

if (TryGetComponent(out StandaloneInputModule im))
#if !ENABLE_LEGACY_INPUT_MANAGER
im.enabled = false;
#else
im.enabled = true;
#endif
#if ENABLE_INPUT_SYSTEM
if (!TryGetComponent(out InputSystemUIInputModule ism))
Debug.LogWarning("You are using the new Input System but the UI Event Manager prefab is not configured to use input from this package. In order to fix the issue, please add and configure a InputSystemUIInputModule component to your Assets/Resources/UIEventManagerPrefab. If the prefab is not present, use the Gameplay Ingredients Wizard located at Window/Gameplay Ingredients/Setup Wizard");
#endif
}
}
public void FocusUI(Selectable selectable)
{
// Before selecting, we ensure that there's no selection in the EventSystem
m_EventSystem.SetSelectedGameObject(null);
if(selectable != null)
selectable.Select();
}
}
}

196
Runtime/Input/InputSystemUtility.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;