Skip to content

Wrapper for InputSystem with continuous OnPressed event implementation.

License

Notifications You must be signed in to change notification settings

vvrvvd/Unity-Simple-Input

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity Simple Input

Unity 2020.1+ License: MIT

Table Of Contents

Introduction

Unity Simple Input is a simple wrapper for Unity InputSystem with custom input action set generator and continuous OnPressed event implementation.

Features

  • 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

System Requirements

Unity 2020.1 or newer.

Dependencies

Input System

Editor Toolbox

Installation

  1. 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
  1. You can also install Simple Input by simply downloading repository zip file and copying Assets folder content to your Unity project.

Overview

Generating actions

Actions are grouped in action sets and may be created through scriptable object generator:

  1. Create new scriptable Action Set Generator in Project view (Simple Input->Input System->Input Action Set).

  2. Set Script Name, Relative Namespace and add actions with bindings to Action Set Template list.

  3. Click Generate script button to generate Action Set Script.

Using actions

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.

  1. Create an instance of your InputActionSet in code:
testActionSet = new TestActionSet();
  1. Register the instance to your InputSystemSimpleManager:
inputSystemManager.RegisterInputActionSet(testActionSet);
  1. Bind events to actions:
testActionSet.Run.BindEvent(Run, InputEventType.Down);
testActionSet.Move.BindEvent(Move);

...

private void Run();
private void Move(Vector2 input);
  1. You can also unbind events from actions:
testActionSet.Run.UnbindEvent(Run, InputEventType.Down);
testActionSet.Move.UnbindEvent(Move);

License

MIT