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

如何解决UnityEngine.EventSystems中的InvalidOperationException错误

Unity新旧输入系统切换后EventSystem报错的解决办法

问题根源

切换到新输入系统后,UGUI默认的StandaloneInputModule仍在调用旧的UnityEngine.Input接口,直接引发了输入处理模式的冲突报错。

具体修复步骤

  • 找到场景中的EventSystem对象,移除自带的StandaloneInputModule组件,添加InputSystemUIInputModule(需确保已安装新输入系统包)。
  • 进入Edit > Project Settings > Player,确认Active Input Handling已设置为Input System Package (New),若之前修改后未重启Unity,现在重启项目让设置生效。
  • 全局搜索项目代码,将所有使用UnityEngine.Input的代码(如Input.GetAxis、Input.GetButtonDown等)替换为新输入系统的实现,比如通过InputAction绑定输入逻辑。
  • 若以上步骤无效,关闭Unity后删除项目根目录下的Library文件夹,重新打开项目让Unity重新生成缓存文件。

报错日志

InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
UnityEngine.EventSystems.BaseInput.GetButtonDown (System.String buttonName) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/BaseInput.cs:126)
UnityEngine.EventSystems.StandaloneInputModule.ShouldActivateModule () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:227)
UnityEngine.EventSystems.EventSystem.Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:474)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.30 23:06:33