Getting started with Unity's new input system InputSystem

I. Introduction

Recently, the Unity version has been fully upgraded to Unity2021, and the shaders also fully use URP. Next, there is no doubt that the input system will also be fully upgraded. This is what Unity officials want us to do. After all, it is now 2023. Our technology is Need to keep pace with the times.

2. Differences between old and new versions

The old version of the InputSysten system is actually just an Input static class. The official has reserved some commonly used inputs for us to use. Generally, it is enough, but it cannot quickly meet many of our individual needs, such as multiple devices. Input, switch input, custom input, custom input return value, etc., are either impossible to implement, or need to be implemented in a more complicated way.

The input method of the new version is a system for completely customizing the input method. And what we define is not a button, but an action behavior. When using it, we only need to monitor the corresponding action behavior, and don't care about the button corresponding to the behavior. In this way, we can change the device and input at any time. way out.

Friends who know Unreal Engine should know that Unreal Engine is a custom InputSystem. Custom InputSystem is a bit more obvious, and it is easier to expand and modularize.

Well, without further ado, let us now fully learn about the new version of InputSystem

3. Features of the new version

Separation of actions and input controls

Just now we mentioned that Actions separates the logical meaning of the input from the Controls of the device. What's the point of this?

If there is no Actions, the meaning of our input and device controls will eventually be hard-coded in the script. Although it can be implemented quickly, it cannot be compatible with different input methods of different devices. In this era of changing devices, it seems very

Guess you like

Origin blog.csdn.net/qq563129582/article/details/130397147