Galaxy Shooter 2D — New Input System #17
Ditching the old Unity Input System for the new and improved one

You’ve probably heard already about the new Unity Input System, which allows for more complex input handling behaviour and flexibility than the old system it had. Honestly, if you are still using the old one, I truly recommend you to switch. It will make your life easier!
Up until now, I have been using the old one to quickly prototype the game. I will explain in this article how I switched and the basic use of the New Input System.
Switching from Old to New
The New Input System comes as a Unity Official Package (use Unity version 2018 or newer). You can find it and install it in the Package Manager window (Window > Package Manager
).

Once you install it, a new window will pop-up asking you if you want to completely disable the old Input System from your Unity project. That’s up to you. You could exclusively use the new one, or both at the same time if you’d like. If you later change your mind, you can always change it in Project Settings > Player > Active Input Handling
.


Creating Input Actions
Add a Player Input component to your Player Controller (in my case, my Player Ship), and click on the Create Actions… button. A new window will show up asking for a location to store a file with all your future inputs.

Now click on the newly generated file, and click on Edit Asset (or just double click it). A special window will open, displaying some action maps generated by default.

The Move and Fire Actions are the only actions I need for now. I’ll let you explore a bit on your own how to create new maps and actions. Try to play with it (that’s how most of us learnt).
Using Inputs
There are various ways to handle these Inputs, but the one I chose to use is through Invoking Unity Events in the Player Input component.

If you click on the Events dropdown, the Editor will show a list with Input Action events, which they all pass a InputSystem.CallbackContext value. In code, we must create a public method with a parameter of that type.

Because the CallbackContext doesn’t return any value, we must access the method ReadValue<>() to obtain it.

Conclusion
This was rather a small and brief introduction to the new Input System, but good enough to get you going. I always suggest you look at some other in-depth videos, and once you get a grip of the system, take a look at the API.