原来代码里
if(Input.GetKeyDown(KeyCode.D))或者if(Input.GetKeyDown(“d”))
后来在Input Manager配置了虚拟轴,以Fire1为例,if(Input.GetKeyDown(“Fire1”))。
结果出现了UnityException: Input Key named: Fire1 is unknown UnityEngine.Input.GetKeyDown (System.String name)
正确结果应为:if(Input.GetButtonDown(“Fire1”))
GetButtonDown才是对应虚拟按钮的,GetKeyDown只对应键值。
另外首字母没有大写也是经常犯的错误,比如horizontal.