Unity Simple Input is a simple wrapper for Unity InputSystem with custom input action set generator and continuous OnPressed event implementation.
- Input action sets script generator
- Three types of Actions: button, float, and Vector2
- Gamepad, Keyboard, and Mouse bindings
- OnPressed event invoked every frame the action is being active
Unity 2020.1 or newer.
- The package is available in Unity Package Manager via git URL. Follow up this Unity page for detailed instructions. Git URL:
https://github.com/vvrvvd/Unity-Simple-Input.git#upm
- You can also install Simple Input by simply downloading repository zip file and copying Assets folder content to your Unity project.
Actions are grouped in action sets and may be created through scriptable object generator:
-
Create new scriptable Action Set Generator in Project view (
Simple Input->Input System->Input Action Set
). -
Set Script Name, Relative Namespace and add actions with bindings to Action Set Template list.
-
Click Generate script button to generate Action Set Script.
To use actions you must first create instance of InputSystemSimpleManager class and invoke it's Update method every frame. There is a MonoBehaviour wrapper implementation for InputSytemSimpleManager called InputSystemSimpleMonoManager that you may simply add to your scene.
- Create an instance of your InputActionSet in code:
testActionSet = new TestActionSet();
- Register the instance to your InputSystemSimpleManager:
inputSystemManager.RegisterInputActionSet(testActionSet);
- Bind events to actions:
testActionSet.Run.BindEvent(Run, InputEventType.Down);
testActionSet.Move.BindEvent(Move);
...
private void Run();
private void Move(Vector2 input);
- You can also unbind events from actions:
testActionSet.Run.UnbindEvent(Run, InputEventType.Down);
testActionSet.Move.UnbindEvent(Move);