可以用EventSystem.current.IsPointerOverGameObject()來判斷 ui上即爲true
或者用射線碰撞自己檢測每個canvas。
private bool CheckUIRaycast() {
PointerEventData eventData = new PointerEventData(EventSystem.current);
eventData.pressPosition = Input.mousePosition;
eventData.position = Input.mousePosition;
List result = new List();
EventSystem.current.RaycastAll(eventData, result);
return result.Count > 0;
}