前提是UI组件上要有BoxCollider,其次用下面两个字段来判断是否点击UI。

UICamera.isOverUI

Whether the last raycast was over the UI.

最后一次光线投射是否在UI上。

UICamera.uiHasFocus

Much like 'isOverUI', but also returns 'true' if there is currently an active mouse press on a UI element, or if a UI input has focus.

很像“isOverUI”,但如果当前在UI元素上有活动的鼠标按压,或者UI输入有焦点,则也会返回“true”。

最后更新于 2024-06-20