【发布时间】:2022-08-20 15:55:30
【问题描述】:
我有一个InputAction 回调,我正在记录玩家点击屏幕的位置,但是只要如果点击不在 UI 元素上。这是我的代码
private void OnPress(InputAction.CallbackContext context)
{
if (!EventSystem.current.IsPointerOverGameObject())
{
this.pressPosition = Mouse.current.position.ReadValue();
}
}
这一直在正常工作。但是,我最近更新了 Unity 版本,现在每次单击游戏中的某个位置时都会收到此警告:
Calling IsPointerOverGameObject() from within event processing (such as from InputAction callbacks)
will not work as expected; it will query UI state from the last frame
根据changelog,此警告是在对输入系统的更新中添加的。
当玩家点击屏幕而没有收到此警告时,有没有办法确定鼠标是否在 UI 上?
标签: unity3d