Implement pause functionality with UI and input bindings

This commit is contained in:
2025-12-13 16:13:22 +01:00
parent 4ae41b3ce9
commit c1d0af9a39
7 changed files with 354 additions and 4 deletions

View File

@@ -181,6 +181,15 @@ public partial class @InputSystem_Actions: IInputActionCollection2, IDisposable
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Pause"",
""type"": ""Button"",
""id"": ""0d2f71b9-572d-45ca-8ce3-c150b120d654"",
""expectedControlType"": """",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
@@ -590,6 +599,28 @@ public partial class @InputSystem_Actions: IInputActionCollection2, IDisposable
""action"": ""StartGame"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""f0dd9d3e-03b2-4d73-9a5b-3c59a85c49ee"",
""path"": ""<Keyboard>/escape"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Pause"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""ad5638d0-68fe-4a6c-9cd4-ca6679aa0360"",
""path"": ""<Gamepad>/start"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Pause"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
},
@@ -1185,6 +1216,7 @@ public partial class @InputSystem_Actions: IInputActionCollection2, IDisposable
m_Player_Next = m_Player.FindAction("Next", throwIfNotFound: true);
m_Player_Sprint = m_Player.FindAction("Sprint", throwIfNotFound: true);
m_Player_StartGame = m_Player.FindAction("StartGame", throwIfNotFound: true);
m_Player_Pause = m_Player.FindAction("Pause", throwIfNotFound: true);
// UI
m_UI = asset.FindActionMap("UI", throwIfNotFound: true);
m_UI_Navigate = m_UI.FindAction("Navigate", throwIfNotFound: true);
@@ -1288,6 +1320,7 @@ public partial class @InputSystem_Actions: IInputActionCollection2, IDisposable
private readonly InputAction m_Player_Next;
private readonly InputAction m_Player_Sprint;
private readonly InputAction m_Player_StartGame;
private readonly InputAction m_Player_Pause;
/// <summary>
/// Provides access to input actions defined in input action map "Player".
/// </summary>
@@ -1340,6 +1373,10 @@ public partial class @InputSystem_Actions: IInputActionCollection2, IDisposable
/// </summary>
public InputAction @StartGame => m_Wrapper.m_Player_StartGame;
/// <summary>
/// Provides access to the underlying input action "Player/Pause".
/// </summary>
public InputAction @Pause => m_Wrapper.m_Player_Pause;
/// <summary>
/// Provides access to the underlying input action map instance.
/// </summary>
public InputActionMap Get() { return m_Wrapper.m_Player; }
@@ -1395,6 +1432,9 @@ public partial class @InputSystem_Actions: IInputActionCollection2, IDisposable
@StartGame.started += instance.OnStartGame;
@StartGame.performed += instance.OnStartGame;
@StartGame.canceled += instance.OnStartGame;
@Pause.started += instance.OnPause;
@Pause.performed += instance.OnPause;
@Pause.canceled += instance.OnPause;
}
/// <summary>
@@ -1436,6 +1476,9 @@ public partial class @InputSystem_Actions: IInputActionCollection2, IDisposable
@StartGame.started -= instance.OnStartGame;
@StartGame.performed -= instance.OnStartGame;
@StartGame.canceled -= instance.OnStartGame;
@Pause.started -= instance.OnPause;
@Pause.performed -= instance.OnPause;
@Pause.canceled -= instance.OnPause;
}
/// <summary>
@@ -1806,6 +1849,13 @@ public partial class @InputSystem_Actions: IInputActionCollection2, IDisposable
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
void OnStartGame(InputAction.CallbackContext context);
/// <summary>
/// Method invoked when associated input action "Pause" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
/// </summary>
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
void OnPause(InputAction.CallbackContext context);
}
/// <summary>
/// Interface to implement callback methods for all input action callbacks associated with input actions defined by "UI" which allows adding and removing callbacks.