I have a scene where I use 2 canvases:
1 canvas is Screen Space Overlay and have 3 zones-images where pointer can enter to blend between cameras
2 canvas is world space and have buttons to do some logic
Problem is that images of first canvas blocks raycasts and doesn’t call IPointerHandler on graphics behind.
The only solution I found is to create own eventData and make raycast through all:
private bool IsPointerOverClickableElement() {
PointerEventData eventData = new PointerEventData(EventSystem.current);
eventData.position = PointerPosition;
List<RaycastResult> results = new List<RaycastResult>();
EventSystem.current.RaycastAll(eventData, results);
foreach (var result in results) {
if (result.gameObject.GetComponent<IPointerClickHandler>() != null) {
if (!result.gameObject.CompareTag("MobileButton")) {
return true;
}
}
}
return false;
}
But its still feels bad because it doesn
t work with IPointerEnterHandler etc.