You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity中ArgumentException:Input Button Fire1未设置问题求助

解决Unity中Fire1输入未设置的错误

问题原因

你遇到的错误是因为Unity的输入系统找不到名为Fire1的输入绑定,这通常和你使用的输入系统版本(旧版Input Manager/新版Input System)或者输入轴配置有关。

解决方案分两种情况:

情况1:使用默认的旧版Input Manager

  1. 打开Unity编辑器顶部菜单:Edit > Project Settings
  2. 在左侧面板选择Input Manager,找到Axes列表
  3. 检查列表中是否存在Fire1:
    • 如果不存在,点击Axes旁的+按钮添加新轴:
      • Name:输入Fire1(大小写必须完全一致)
      • Positive Button:设置为你想用的触发按键(比如鼠标左键填mouse 0,左Ctrl填left ctrl)
      • Type:选择Key/Mouse Button
  4. 保存设置后重新运行游戏

情况2:使用新版Input System(Unity 2019+可选安装)

如果你的项目安装了Input System包,旧版Input.GetButtonDown()API会失效,需要改用新系统的写法:

  1. 先确认输入系统激活状态:Edit > Project Settings > Player > Other Settings,将Active Input Handling设置为Input System Package或Both
  2. 修改你的Player脚本为新API示例:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem; // 引入新输入系统命名空间

public class Player : MonoBehaviour
{
    [SerializeField] Vector2 jumpVelocity;
    private Keyboard keyboard;

    void Awake()
    {
        keyboard = Keyboard.current; // 获取键盘输入实例
    }

    void Update()
    {
        // 这里用左Ctrl触发,你可以换成其他按键比如keyboard.spaceKey
        if (keyboard.leftCtrlKey.wasPressedThisFrame)
        {
            GetComponent<Rigidbody2D>().velocity = jumpVelocity;
        }
    }
}

或者你也可以通过创建Input Action Asset来可视化配置输入绑定,更适合复杂项目。

额外排查点

  • 检查Input Manager中的Fire1是否拼写错误(比如把1写成了l)
  • 如果切换输入系统后出现其他错误,重启Unity编辑器确保设置生效

内容的提问来源于stack exchange,提问作者MegaMindTheCoder

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 14:20:28