This asset for Unity is a powerful Input System Manager that allows you to easily retrieve data from the Input System using Scriptable Objects as references to Input Actions. With this Singleton-based solution, you'll be able to speed up the process of game development and create a more intuitive user experience for your players.
- Singleton/Instance based script for easy global access.
- Plug'n'Play, just add your Input Action Asset and references to the Manager and start reading inputs!
- Key rebinding support.
- 2 methods to read inputs: Scriptable Objects and Strings!
- Simple one-line code to read any inputs.
- Perfect for Single-Player and Networked Multiplayer.
- Local Multiplayer/Split-Screen is not supported.
- Only one Action Map is supported.
- Download the asset and import to your Project.
- Create a new
Empty Game Object
and add theInputManager.cs
component to it. - Create and configure a new
Input Actions
Asset. (Don't forget to install theInput System package
from thePackage Manager
). - Drag and Drop or Select the
Input Actions
Asset in theInputManager
component. - Create reference/s for the asset clicking
Create > Scriptable Objects > Input Manager > InputActionReference
, providing theName
and theType
of the Action. - Add the reference/s to the
Input Manager
component's array. - That's all. Now you can retrieve data from the actions by calling code from the InputManager's Instance.
You can retrieve data from the Input System Manager by using one of the 2 types as a reference.
public InputActionReference moveActionReference; // Vector2
public InputActionReference shootActionReference; // Button
private void Update() {
if(InputManager.Instance.GetInputActionValue(moveActionReference, out Vector2 moveInputValue)) {
// Movement Code
}
if(InputManager.Instance.GetInputActionValue(shootActionReference, InputActionState.WasPressedThisFrame)) {
// Shooting Code
}
}
private void Update() {
if(InputManager.Instance.GetInputActionValue("Movement", out Vector2 moveInputValue)) {
// Movement Code
}
if(InputManager.Instance.GetInputActionValue("Fire", InputActionState.WasPressedThisFrame)) {
// Shooting Code
}
}
public bool AddInputActionReference(InputActionReference inputActionReference)
public bool GetInputActionValue(InputActionReference reference, out Vector2 value)
public bool GetInputActionValue(string inputActionName, out Vector2 value)
public bool GetInputActionValue(InputActionReference reference, InputActionState inputActionState)
public bool GetInputActionValue(string inputActionName, InputActionState inputActionState)
public InputActionReference GetInputReference(InputAction action)
public InputAction GetInputAction(InputActionReference reference)
public InputAction GetInputAction(string inputActionName)
public Vector2 GetMouseScreenPosition()
public void PerformInputActionRebind(InputActionReference inputActionReference, int bindingIndex)
public void PerformInputActionRebind(InputAction inputAction, int bindingIndex)
public string GetBindingDisplayString(InputAction inputAction, int bindingIndex)
public string GetBindingDisplayString(InputActionReference inputActionReference, int bindingIndex)
public string GetBindingDisplayString(string inputActionName, int bindingIndex)