How Can We Help?

Setup

Setup

To use Easy Input, follow these simple steps:

1. Create a new project or open an existing one

Follow the standard practice for creating or opening a scene. Nothing special here.

2. Add this package to your project

Import the package files from the Unity Asset Store.

3. Add the Easy Input Source to your scene

Typically, you’d add an empty GameObject to your scene,
name it something like ‘Input Source’, and add the Easy
Input Source as a component to that GameObject.

This works well in two ways:

1. It provides a way of saving the input settings with the
scene. So, for example, if you enable the Xbox controller…
it stays enabled for the project.

2. It provides a way of accessing the Easy Input
InputManager ‘locally’.

What I mean by that is InputManager is a static class and
can be accessed anywhere. However, sometimes it’s
better to specify a specific input source and access it as a
variable as opposed to a singleton. This would allow you
to have multiple input sources in a single scene that point
to different input devices.

 

 

4. Add the core Input Manager Entries

 

With the Easy Input Source added, simply press the ‘Reset Input Entries’ button.
This will create the required Unity Input Manager entries. If the entries currently exist, it will delete them first and then re-create them.

* In previous versions of Easy Input, there was a zip file whose contents replaced the InputManager.asset file. That is no longer needed.

 

 

5. Setup ‘Action Aliases’

Action aliases allow you to set up custom names that you can look for in the code. This allows you to map multiple inputs to a single action. So, instead of testing input for “spacebar” or “button1”, you can test for the action
“Jump” instead. It provides for a much cleaner approach and also allows for input settings to be changed at runtime.

 

With this version of Easy Input, you can register Action Aliases directly in
the UI. These will be the default aliases that will be setup once you start
your game. During runtime, you can modify these defaults as needed.

When accessing Action Aliases in code, you can simply do a call like this:

bool lIsPressed = InputManager.IsJustPressed("Jump"))

 

In the image above, you can see where you add and remove action
aliases. By clicking on an item in the list, you can modify its properties:

Name – Key used to test the action from code.

Description – Friendly description to remind you of what the alias is for.

Primary Input – Input key or button that the alias references.

 

Support Input – Additional key required for the Primary Input to be valid. For example, if the Primary Input is “Q” and the Support Input is “Left Shift”, the action won’t register as active unless both “Q” and “Left Shift” are pressed.

 

While coding, it’s much better to test input based on the action you want vs. the actual input.

For example, Let’s say the player can jump by pressing the space-bar, right-clicking the mouse, or pressing ‘A’ on the Xbox controller.
Instead of having complex conditions, you can set up an ‘Action Alias’ by doing this:

InputManager.AddAlias("Jump", EnumInput.SPACE);
InputManager.AddAlias("Jump", EnumInput.GAMEPAD_0_BUTTON);
InputManager.AddAlias("Jump", EnumInput.MOUSE_RIGHT_BUTTON);

Now, to test if it’s time to jump, you can just do this:

if (InputManager.IsJustPressed("Jump"))
{
// Do jump
}

 

Setup as many aliases as you need to. See ‘Action Aliases’ for more detail.

 

Optional

6. Setup Unity Input Manager entries

With this version of Easy Input, you can access Unity’s Input Manager entries with Ootii’s Input Manager or register ‘Action Aliases’ directly through Easy Input.

When accessing Unity’s Input Manager entries, you can simply do a call like
this:

bool lIsPressed = InputManager.IsJustPressed("Fire1"))

You don’t need to do any other setup. However, it should be noted that you
can’t take advantage of Easy Input’s advanced information and features that
track things like how long the button has been pressed, is it double-clicked,
etc.

So, I prefer to set the Action Aliases through Easy Input…

 

7. Customize Action Alias Defaults

Several aliases already exist to support generic actions like ‘Movement’ and ‘View’. You can customize these, remove them, or add to them if needed.

See ‘Action Aliases’ for more detail.

 

Page Contents