First off, I am using the Input System. I am encountering what appears to be a bug that occurs when both of these criteria are met:
- Dragging a GameObject using the DragHandler interface.
- There is a different GameObject under the cursor that is below the dragged object in the hierarchy.
In this case, PointerDown events are not triggered on the object being dragged. To clarify:
- I’m dragging with left click and calling OnPointerDown with right click.
- OnPointerDown works if there is nothing below the dragged object in the hierarchy.
- This occurs regardless of whether or not the object below the dragged object implements IPointerDownHandler (in fact, it happens even on objects with no attached scripts).
This seems like a bug because objects that do not implement IPointerDownHandler seem to be intercepting inputs and blocking them for objects that do implement it.
I am exclusively using UI objects (Panels, Images, and TMP text) on a Screen Space Overlay canvas.
public void OnDrag(PointerEventData eventData)
{
transform.position = eventData.position;
}
public void OnPointerDown(PointerEventData data)
{
if (data.button == PointerEventData.InputButton.Right)
{
Debug.Log("pointer down");
}
}
EDIT: Disabling Raycast Target on the interfering objects does not fix this issue; however, adding a Canvas Group and disabling Block Raycasts does appear to fix it.