【Unity踩坑】使用Input System后UI EventSystem的冲突

在项目中使用Input System,在UI中添加了元素后,再次运行出现下面的错误:

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.

在Hierarchy中选中EventSystem,可以看到如下提示:

You are using StandaloneInputModele, which uses the old InputManager. You are using the new InputSystem, and have the old InputManager disabled. StandaloneInputModule will not work. Click the button below to replace this component with a InputSystemUIInputModule, which uses the new InputSystem.

您正在使用 StandaloneInputModele,它使用旧的 InputManager。您正在使用新的 InputSystem,并且已禁用旧的 InputManager。StandaloneInputModule 将不起作用。单击下面的按钮将此组件替换为使用新 InputSystem 的 InputSystemUIInputModule。

所以呢,有两种解决方案

一是在Project Setting中开启两种输入方式,二是将EventSystem中的StandaloneInputModule升级为InputSystemUIInputModule。

方法一

Edit > Project Settings > Player > Configuration > Active Input Handling > Both

方法二:在EventSystem中,点击 “Replace With InputSystemUIInputModule” 按钮。下图是升级后的设置。

参考:

Unity: Conflict between new InputSystem and old EventSystem - Stack Overflow

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

tealcwu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值