使用 Input 设置(顶部菜单:Edit > Project Settings,然后选择 Input 类别)可定义项目的输入轴和游戏操作。
要添加更多输入轴,请增大 Size 属性中的值。
每个输入轴提供以下属性列表:
属性 | 功能 | |
---|---|---|
Name | 输入指代游戏启动器中的轴并通过脚本引用的字符串。 | |
Descriptive Name | 输入游戏启动器中显示的 Positive Button 功能的详细定义。 | |
Descriptive Negative Name | 输入游戏启动器中显示的 Negative Button 功能的详细定义。 | |
Negative Button | 输入向轴发送负值的按钮的名称。 | |
Positive Button | 输入向轴发送正值的按钮的名称。 | |
Alt Negative Button | 输入向轴发送负值的辅助按钮的名称。 | |
Alt Positive Button | 输入向轴发送正值的辅助按钮的名称。 | |
Gravity | 设置输入重新居中的速度。仅当 Type 设置为 key / mouse button 时,此属性才适用。 | |
Dead | 任何小于此数字的正值或负值都视为零。适用于游戏杆。 | |
Sensitivity | 对于键盘输入,值越大,响应越快。较小的值将更加平滑。对于鼠标增量,该值会缩放实际鼠标增量。 | |
Snap | 启用此选项可在接收相反输入后立即将轴值重置为零。仅当 Type 设置为 key / mouse button 时,此属性才适用。 | |
Invert | 启用此选项可使正值按钮向轴发送负值,反之亦然。 | |
Type | 选择此轴期望的输入类型。 | |
Key / Mouse Button | 任何一种按钮。 | |
Mouse Movement | 鼠标增量和滚轮。 | |
Window Movement | 用户移动窗口。 | |
Joystick Axis | 模拟游戏杆轴。 | |
轴 | 选择来自设备(游戏杆、鼠标、游戏手柄等)的输入轴。默认为 X 轴。 | |
Joy Num | 选择应该使用哪个游戏杆。默认为从所有游戏杆检索输入。 注意:这仅用于输入轴而不是按钮。 |
在 Input 设置中设置的所有轴都有两个用途:
游戏启动器提供所有已定义的轴,并显示每个轴的名称、详细描述和默认按钮。在此处,可以更改轴中定义的任何按钮。因此,最好使用轴(而不是单个按钮)来编写脚本,因为玩家可能希望自定义游戏按钮。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.