繁体   English   中英

使用统一引擎时,我收到错误 ArgumentException: Input Button w is not setup。 要更改输入设置,请使用:编辑 -> 设置 -> 输入

[英]When using unity engine I get the error ArgumentException: Input Button w is not setup. To change the input settings use: Edit -> Settings -> Input

是的,所以我对统一非常陌生,并且对我在做什么几乎零线索,这可能导致了这个错误。

无论如何,我真的不知道该尝试什么。 w 被定义为alt verticle。 所以我真的很想知道为什么这是错误的。 如果有人能给我一个很棒的建议。

这是我的代码:

    if(Input.GetButtonDown("w")){
        transformY += 1;
    }
    if(Input.GetButtonDown("s")){
        transformY += -1;
    }

    if(Input.GetButtonDown("a")){
        transformX += 1;
    }
    if(Input.GetButtonDown("d")){
        transformX += -1;
    }

    transform.position = new Vector2(transformX, transformY);

这意味着该按钮未设置。

要编辑、设置或删除按钮及其名称: 1. Go 到 Edit > Project Settings > Input 以打开 Input Manager。 2. 通过单击旁边的箭头来展开 Axis。 这显示了您拥有的当前按钮的列表。 您可以使用其中之一作为参数“buttonName”。 3. 展开列表中的一项以访问和更改按钮名称和触发它的键、操纵杆或鼠标移动等方面。

来源(我建议您阅读文章): https://docs.unity3d.com/ScriptReference/Input.GetButtonDown.html

有关统一输入管理器的更多信息: https://docs.unity3d.com/Manual/class-InputManager.html

在大多数情况下,特别是如果您只有键盘键,您可以简单地使用GetKeyDownKeyCode之类的

if(Input.GetKeyDown(KeyCode.W))
{
    transformY += 1;
}
if(Input.GetKeyDown(KeyCode.S))
{
    transformY += -1;
}

if(Input.GetKeyDown(KeyCode.A))
{
    transformX += 1;
}
if(Input.GetKeyDown(KeyCode.D))
{
    transformX += -1;
}

transform.position = new Vector2(transformX, transformY);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM