Skip to content
Snippets Groups Projects
Commit b410d499 authored by Merle Krauss's avatar Merle Krauss
Browse files

Try New Input System

parent b8bf3b67
Branches
No related tags found
No related merge requests found
......@@ -36,14 +36,6 @@
"expectedControlType": "Vector2",
"processors": "",
"interactions": ""
},
{
"name": "Pause",
"type": "Button",
"id": "508d585c-3793-4ab1-b691-e630e16802c1",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
}
],
"bindings": [
......@@ -200,10 +192,26 @@
"action": "Look",
"isComposite": false,
"isPartOfComposite": false
}
]
},
{
"name": "UI",
"id": "565893da-00d1-4f69-8c99-7c11f586b02d",
"actions": [
{
"name": "Pause",
"type": "Button",
"id": "26631492-c02a-45d0-bdd6-ab1d9442ae0e",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
}
],
"bindings": [
{
"name": "",
"id": "de4044f7-5651-40fe-9aca-c711c51d758e",
"id": "e524f7f4-da89-4d98-ad6a-e5f46266e648",
"path": "<Keyboard>/escape",
"interactions": "",
"processors": "",
......
......@@ -49,14 +49,6 @@ public class @PlayerInput : IInputActionCollection, IDisposable
""expectedControlType"": ""Vector2"",
""processors"": """",
""interactions"": """"
},
{
""name"": ""Pause"",
""type"": ""Button"",
""id"": ""508d585c-3793-4ab1-b691-e630e16802c1"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """"
}
],
""bindings"": [
......@@ -213,10 +205,26 @@ public class @PlayerInput : IInputActionCollection, IDisposable
""action"": ""Look"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
},
{
""name"": ""UI"",
""id"": ""565893da-00d1-4f69-8c99-7c11f586b02d"",
""actions"": [
{
""name"": ""Pause"",
""type"": ""Button"",
""id"": ""26631492-c02a-45d0-bdd6-ab1d9442ae0e"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """"
}
],
""bindings"": [
{
""name"": """",
""id"": ""de4044f7-5651-40fe-9aca-c711c51d758e"",
""id"": ""e524f7f4-da89-4d98-ad6a-e5f46266e648"",
""path"": ""<Keyboard>/escape"",
""interactions"": """",
""processors"": """",
......@@ -264,7 +272,9 @@ public class @PlayerInput : IInputActionCollection, IDisposable
m_Player_Jump = m_Player.FindAction("Jump", throwIfNotFound: true);
m_Player_Attack = m_Player.FindAction("Attack", throwIfNotFound: true);
m_Player_Look = m_Player.FindAction("Look", throwIfNotFound: true);
m_Player_Pause = m_Player.FindAction("Pause", throwIfNotFound: true);
// UI
m_UI = asset.FindActionMap("UI", throwIfNotFound: true);
m_UI_Pause = m_UI.FindAction("Pause", throwIfNotFound: true);
}
public void Dispose()
......@@ -318,7 +328,6 @@ public class @PlayerInput : IInputActionCollection, IDisposable
private readonly InputAction m_Player_Jump;
private readonly InputAction m_Player_Attack;
private readonly InputAction m_Player_Look;
private readonly InputAction m_Player_Pause;
public struct PlayerActions
{
private @PlayerInput m_Wrapper;
......@@ -327,7 +336,6 @@ public class @PlayerInput : IInputActionCollection, IDisposable
public InputAction @Jump => m_Wrapper.m_Player_Jump;
public InputAction @Attack => m_Wrapper.m_Player_Attack;
public InputAction @Look => m_Wrapper.m_Player_Look;
public InputAction @Pause => m_Wrapper.m_Player_Pause;
public InputActionMap Get() { return m_Wrapper.m_Player; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
......@@ -349,9 +357,6 @@ public class @PlayerInput : IInputActionCollection, IDisposable
@Look.started -= m_Wrapper.m_PlayerActionsCallbackInterface.OnLook;
@Look.performed -= m_Wrapper.m_PlayerActionsCallbackInterface.OnLook;
@Look.canceled -= m_Wrapper.m_PlayerActionsCallbackInterface.OnLook;
@Pause.started -= m_Wrapper.m_PlayerActionsCallbackInterface.OnPause;
@Pause.performed -= m_Wrapper.m_PlayerActionsCallbackInterface.OnPause;
@Pause.canceled -= m_Wrapper.m_PlayerActionsCallbackInterface.OnPause;
}
m_Wrapper.m_PlayerActionsCallbackInterface = instance;
if (instance != null)
......@@ -368,13 +373,43 @@ public class @PlayerInput : IInputActionCollection, IDisposable
@Look.started += instance.OnLook;
@Look.performed += instance.OnLook;
@Look.canceled += instance.OnLook;
}
}
}
public PlayerActions @Player => new PlayerActions(this);
// UI
private readonly InputActionMap m_UI;
private IUIActions m_UIActionsCallbackInterface;
private readonly InputAction m_UI_Pause;
public struct UIActions
{
private @PlayerInput m_Wrapper;
public UIActions(@PlayerInput wrapper) { m_Wrapper = wrapper; }
public InputAction @Pause => m_Wrapper.m_UI_Pause;
public InputActionMap Get() { return m_Wrapper.m_UI; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(UIActions set) { return set.Get(); }
public void SetCallbacks(IUIActions instance)
{
if (m_Wrapper.m_UIActionsCallbackInterface != null)
{
@Pause.started -= m_Wrapper.m_UIActionsCallbackInterface.OnPause;
@Pause.performed -= m_Wrapper.m_UIActionsCallbackInterface.OnPause;
@Pause.canceled -= m_Wrapper.m_UIActionsCallbackInterface.OnPause;
}
m_Wrapper.m_UIActionsCallbackInterface = instance;
if (instance != null)
{
@Pause.started += instance.OnPause;
@Pause.performed += instance.OnPause;
@Pause.canceled += instance.OnPause;
}
}
}
public PlayerActions @Player => new PlayerActions(this);
public UIActions @UI => new UIActions(this);
private int m_Keyboard_and_MouseSchemeIndex = -1;
public InputControlScheme Keyboard_and_MouseScheme
{
......@@ -399,6 +434,9 @@ public class @PlayerInput : IInputActionCollection, IDisposable
void OnJump(InputAction.CallbackContext context);
void OnAttack(InputAction.CallbackContext context);
void OnLook(InputAction.CallbackContext context);
}
public interface IUIActions
{
void OnPause(InputAction.CallbackContext context);
}
}
......@@ -5,6 +5,7 @@ using UnityEngine;
public class PauseMenu : MonoBehaviour
{
public static bool GameIsStopped = false;
public GameObject menuUI;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment