Version: 2019.3
Graphics
Physics

Ввод

Use the Input settings (top menu: Edit > Project Settings, then select the Input category) to define the input axes and game actions for your Project.

Input settings
Input settings

To add more input axes, increase the value in the Size property.

Each input axis provides the following list of properties:

Свойство: Функция:
Имя Enter the string that refers to the axis in the game launcher and through scripting.
Descriptive Name Enter a detailed definition of the Positive Button function that appears in the game launcher.
Descriptive Negative Name Enter a detailed definition of the Negative Button function that appears in the game launcher.
Negative Button Enter the name of the button that sends a negative value to the axis.
Positive Button Enter the name of the button that sends a positive value to the axis.
Alt Negative Button Enter the name of the secondary button that sends a negative value to the axis.
Alt Positive Button Enter the name of the secondary button that sends a positive value to the axis.
Gravity Set how fast the input re-centers. This property applies only when the Type is key / mouse button.
Dead Any positive or negative values that are less than this number register as zero. Useful for joysticks.
Sensitivity For keyboard input, a larger value results in faster response time. A lower value is smoother. For the mouse delta, this value scales the actual mouse delta.
Snap Enable this option to immediately reset the axis value to zero after it receives opposite inputs. This property applies only when the Type is key / mouse button.
Invert Enable this option to make the positive buttons send negative values to the axis, and vice versa.
Тип Choose what kind of input this axis can expect.
Key / Mouse Button Any kind of button.
Mouse Movement Mouse delta and scrollwheels.
Window Movement User shakes the window.
Joystick Axis Analog joystick axes.
Axis Choose the axis of input from the device (joystick, mouse, gamepad, etc.). Defaults to the X-axis.
Joy Num Choose which joystick should be used. Defaults to retrieving the input from all joysticks.
Note: This is only used for input axes and not buttons.

For further information on naming conventions see documentation on Conventional Game Input.

Using axes during Game Play

All the axes that you set up in the Input settings serve two purposes:

  • They allow you to reference your inputs by axis name in scripting.
  • They allow the players of your game to customize the controls to their liking.

The game launcher presents all defined axes, where it displays the name, detailed description, and default buttons for each. From here, they can change any of the buttons defined in the axes. Therefore, it is best to write your scripts making use of axes instead of individual buttons, as the player may want to customize the buttons for your game.

The game launchers Input settings are displayed when your game runs
The game launcher’s Input settings are displayed when your game runs

For more information see documentation on Input, Input.GetAxis and Input.GetButtonDown in the Scripting Reference.

Graphics
Physics
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961