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

Unity创建新Action遇CS0111错误:PlayerInputActions重复定义OnMove

Unity Input System报错CS0111的解决办法

问题本质

这个报错Assets\PlayerInputActions.cs(286,14): error CS0111: Type 'PlayerInputActions.IPlayerActions' already defines a member called 'OnMove' with the same parameter types,核心是自动生成的输入接口里OnMove方法被重复定义了——要么是你在Input Action配置里加了重复的Move动作,要么是手动修改生成代码时添了重复方法。

一步步解决

  • 找到你的.inputactions后缀的PlayerInputActions资源文件,打开它检查Actions列表:同一Input Map下有没有两个叫Move的Action?有的话删掉多余的。
  • 确认配置里没重复后,在资源文件的Inspector面板点Generate C# Class按钮,重新生成代码——这会覆盖之前出错的文件,清掉重复定义。
  • 要是你之前手动修改过PlayerInputActions.cs(比如自己加了OnMove方法),赶紧删掉手动加的那段,自动生成的代码已经包含了对应Action的接口方法,手动加就会冲突。
  • 要是前面的步骤没用,直接删掉PlayerInputActions.cs文件,再重新点Generate按钮生成新的,确保代码是干净的。
  • 最后清一下缓存:顶部菜单栏点Edit > Clear All PlayerPrefs,再点File > Save Project,重启Unity再编译项目。

内容的提问来源于stack exchange,提问作者Александр

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 10:03:25