使用新的 InputSystem 时。如果我将 Canvas 组件添加到我的场景中,它会自动带来旧的 EventSystem 并且我在控制台中看到此错误:
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.Input.get_mousePosition () (at <213e6bf8f2dd495fbd693e6ce506136b>:0)
UnityEngine.UI.MultipleDisplayUtilities.GetMousePositionRelativeToMainDisplayResolution () (at /Applications/Unity/Hub/Editor/2020.1.14f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/MultipleDisplayUtilities.cs:40)
UnityEngine.EventSystems.BaseInput.get_mousePosition () (at /Applications/Unity/Hub/Editor/2020.1.14f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/InputModules/BaseInput.cs:75)
UnityEngine.EventSystems.StandaloneInputModule.UpdateModule () (at /Applications/Unity/Hub/Editor/2020.1.14f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:175)
UnityEngine.EventSystems.EventSystem.TickModules () (at /Applications/Unity/Hub/Editor/2020.1.14f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:328)
UnityEngine.EventSystems.EventSystem.Update () (at /Applications/Unity/Hub/Editor/2020.1.14f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:343)
Run Code Online (Sandbox Code Playgroud)
小智 59
您可能尝试导入新的输入系统包以实现多个输入设备的兼容性。此类错误是由于新旧输入系统包之间的冲突造成的,并且可能在最新更新中得到解决。要解决此问题,请转到“编辑” -> “项目设置” -> “播放器”-> “配置”下的“其他设置”下的“活动输入处理”选项。选择两者。Unity 将重新启动。现在你的问题应该解决了。您将能够同时使用旧的输入系统包和新的输入系统包。干杯。聚苯乙烯
单击此图像链接可查看这些设置在 Unity 编辑器中的位置。
看起来解决方案是在检查器中的自动更新按钮中:
归档时间: |
|
查看次数: |
4310 次 |
最近记录: |