Unity3D说明文档翻译-Conventional Game Input

Conventional Game Input

常规游戏输入

Unity supports keyboard, joystick and gamepad input.

Unity支持键盘,摇杆和游戏手柄输入.

Virtual axes and buttons can be created in the Input Manager, and end users can configure Keyboard input in a nice screen configuration dialog.

虚拟轴和按钮可以在输入管理器创建,且终端用户可以在一个漂亮的屏幕配置对话框配置键盘输入.

You can setup joysticks, gamepads, keyboard, and mouse, then access them all through one simple scripting interface. Typically you use the axes and buttons to fake up a console controller. Alternatively you can access keys on the keyboard.

你可以设置摇杆,游戏手柄,键盘和鼠标,然后始终通过一个简单的脚本界面使用它们.典型地,你使用轴和按钮来伪装一个控制台控制器.或者,你可以使用键盘上的按键.

Virtual Axes

虚拟轴

From scripts, all virtual axes are accessed by their name.

通过脚本,所以虚拟轴都可以通过它们的名称使用.

Every project has the following default input axes when it’s created:

每一个项目当它创建后都有下面默认输入轴:

· Horizontal and Vertical are mapped to w, a, s, d and the arrow keys.

· Fire1Fire2Fire3 are mapped to Control, Option (Alt), and Command, respectively.

· Mouse X and Mouse Y are mapped to the delta of mouse movement.

· Window Shake X and Window Shake Y is mapped to the movement of the window.

· 横向和竖向被映射到w,a,s,d和方向键.

· 射击1,射击2和射击3被分别映射到ctrl,alt和cmd键.

· 鼠标X和鼠标Y被映射为鼠标的移动.

· 窗口摇动X和窗口摇动Y被映射为窗口的移动.

Adding new Input Axes

添加新输入轴

If you want to add new virtual axes go to the Edit->Project Settings->Input menu. Here you can also change the settings of each axis.

如果你想添加新虚拟轴到编辑>项目设置>输入菜单.这里你也可以改变每一个轴的设置.

You map each axis to two buttons on a joystick, mouse, or keyboard keys.

你映射每个轴到两个按钮在摇杆,鼠标或键盘按键上.

Property:

属性:

Function:

功能:

Name

名称

The name of the string used to check this axis from a script.

用于从脚本选定这个轴的字符串名称.

Descriptive Name

描述名称

Positive value name displayed in the input tab of the Configuration dialog for standalone builds.

配置对话框单独构建的显示在输入标签的正值名称.

Descriptive Negative Name

描述负名称

Negative value name displayed in the Input tab of the Configurationdialog for standalone builds.

配置对话框单独构建的显示在输入标签的负值名称.

Negative Button

负按钮

The button used to push the axis in the negative direction.

用于在轴的负方向增大的按钮

Positive Button

正按钮

The button used to push the axis in the positive direction.

用于在轴的正方向增大的按钮

Alt Negative Button

替代负按钮

Alternative button used to push the axis in the negative direction.

用于在轴的负方向增大的替代按钮.

Alt Positive Button

替代正按钮

Alternative button used to push the axis in the positive direction.

用于在轴的正方向增大的替代按钮

Gravity

重力

Speed in units per second that the axis falls toward neutral when no buttons are pressed.

当按钮按下每秒以单位速度自然下落的轴.

Dead

死亡

Size of the analog dead zone. All analog device values within this range result map to neutral.

模拟死亡区域大小.所有模拟设备值在此范围内映射

Sensitivity

灵敏度

Speed in units per second that the the axis will move toward the target value. This is for digital devices only.

轴移动向目标值的每秒单位速度.这仅用于数字设备.

Snap

急钮

If enabled, the axis value will reset to zero when pressing a button of the opposite direction.

如果激活,当按下反方向键时,轴的值重置为0.

Invert

反转

If enabled, the Negative Buttons provide a positive value, and vice-versa.

如果激活,负按钮提供正值,反之亦然.

Type

打字

The type of inputs that will control this axis.

输入的字将控制轴.

Axis

The axis of a connected device that will control this axis.

连接设备的轴将控制此轴

Joy Num

操纵杆数

The connected Joystick that will control this axis.

连接的操纵杆将控制此轴

Use these settings to fine tune the look and feel of input. They are all documented with tooltips in the Editor as well.

使用这些设置微调输入的视觉和感觉.它们也都记录在编辑器的工具架上.

Using Input Axes from Scripts

从脚本使用输入轴

You can query the current state from a script like this:

你可以像这样通过查询当前状态:

 value = Input.GetAxis ("Horizontal");

An axis has a value between –1 and 1. The neutral position is 0. This is the case for joystick input and keyboard input.

一个轴有一个值在-1和1之间.中间位置是0.这摇杆输入和键盘输入的情况.

However, Mouse Delta and Window Shake Delta are how much the mouse or window moved during the last frame. This means it can be larger than 1 or smaller than –1 when the user moves the mouse quickly.

然而,鼠标移动和窗口摇动是鼠标和窗口在下一帧移动的大小.这意味着当用户飞快移动鼠标它可以比1大和比-1小.

It is possible to create multiple axes with the same name. When getting the input axis, the axis with the largest absolute value will be returned. This makes it possible to assign more than one input device to one axis name. For example, create one axis for keyboard input and one axis for joystick input with the same name. If the user is using the joystick, input will come from the joystick, otherwise input will come from the keyboard. This way you don’t have to consider where the input comes from when writing scripts.

可以用一个相同名称创建多个轴.当获取输入轴,输入轴的最大绝对值将返回.这使得它可以指派多个输入设备通过一个轴名称.如果用户使用摇杆输入将来自摇杆设置,否则输入来自键盘设置.这中方法使得你写脚本时无需考虑输入来自哪里.

Button Names

按钮名称

To map a key to an axis, you have to enter the key’s name in the Positive Button or Negative Button property in the Inspector.

映射一个键到一个轴,你需要在检视面板输入键的名称到正按钮或负按钮属性.

Keys

按键

The names of keys follow this convention:

键的名称如下约定:

· Normal keys(常规键): “a”, “b”, “c” …

· Number keys(数字键): “1”, “2”, “3”, …

· Arrow keys(方向键): “up”, “down”, “left”, “right”

· Keypad keys(小键盘键): “[1]”, “[2]”, “[3]”, “[+]”, “[equals]”

· Modifier keys(修改键): “right shift”, “left shift”, “right ctrl”, “left ctrl”, “right alt”, “left alt”, “right cmd”, “left cmd”

· Mouse Buttons(鼠标键): “mouse 0”, “mouse 1”, “mouse 2”, …

· Joystick Buttons (摇杆键)(from any joystick): “joystick button 0”, “joystick button 1”, “joystick button 2”, …

· Joystick Buttons (from a specific joystick): “joystick 1 button 0”, “joystick 1 button 1”, “joystick 2 button 0”, …

· Special keys(特殊键): “backspace”, “tab”, “return”, “escape”, “space”, “delete”, “enter”, “insert”, “home”, “end”, “page up”, “page down”

· Function keys(功能键): “f1”, “f2”, “f3”, …

· 

· The names used to identify the keys are the same in the scripting interface and the Inspector.

· 定义的名称在脚本接口和检视面板也相同.

 value = Input.GetKey ("a");

Note also that the keys are accessible using the KeyCode enum parameter.

注意:键也可以使用键代码枚举参数.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值