事件不会对额外的鼠标按钮做出反应

Events do not react to extra Mousebuttons

我目前正在为我的 Unity 游戏开发 UI。由于我已经开始创建一个 KeyBinder-Menu,可以在其中重新分配键。这工作正常,直到我尝试为鼠标按钮实现它。

我尝试使用 Event.current.button 所以我可以处理鼠标输入,但首先它一直是 returns 0 当我没有按其他任何东西时然后是 mousebutton 0 其次它没有反应到我额外的鼠标按钮。

然后我尝试了 Input.GetKeyDown(KeyCode.MouseX)(X 将是我想要处理的鼠标按钮)这适用于鼠标按钮 0、1 和 2,但不适用于我的 extrabuttons to。我有一个 Logitech 的鼠标,带有 2 个额外的按钮,它们在所有游戏(如大声笑、Rainbow、minecraft ....)上都能正常工作,所以我不知道为什么 unity 无法处理它们。

感谢所有我可能得到的答案。

目前这是一个错误,我已经提交了关于它的错误报告你可以在这里投票: https://issuetracker.unity3d.com/issues/event-dot-button-only-supports-right-left-and-middle-mouse-buttons

但是 Input.GetMouseButton(x); 仍会正确读取您额外的鼠标按钮,其中 x 是一个整数 例如:Input.GetMouseButton(12); 将读取游戏鼠标上的第 12 个鼠标按钮 ...

还可以做发布、推送事件:

Returns true during the frame the user pressed the given mouse button. Input.GetMouseButtonDown(int button);

Returns whether the given mouse button is held down or not.
Input.GetMouseButton(int button);

Returns true during the frame the user releases the given mouse button. Input.GetMouseButtonUp(int button);

来自 Unity 的更新: 再次感谢您报告此问题。我们的开发人员已经对其进行了审查,不幸的是,已决定不对其进行修复。截至目前,IMGUI 不支持超过 3 个按钮,并且由于 IMGUI 正在被 UIElements 取代,因此不会添加此功能。