代码检查:输入名称未在输入管理器中定义
此检查会报告在项目的 Input Manager 设置中未定义名称时对 Input.GetAxis、 Input.GetButton 及相关 API 的使用。 如果输入名称缺失,调用很可能会在运行时失败。
示例
在此示例中,输入名称 "HorizontalMovement" 未在 Unity 的 Input Manager 中定义。 正确的轴名称应为 "Horizontal"。
using UnityEngine;
public class Example : MonoBehaviour
{
void Update()
{
// Reported: "HorizontalMovement" is not defined in Input Manager
var horizontal = Input.GetAxis("HorizontalMovement");
}
}
using UnityEngine;
public class Example : MonoBehaviour
{
void Update()
{
// "Horizontal" is a standard Unity input axis
var horizontal = Input.GetAxis("Horizontal");
}
}
快速修复
此检查不提供专用的快速修复。 请手动修正该字符串或在 Unity 项目设置中添加缺失的轴/按钮名称。
2026年 5月 8日