OnBeginDrag does not get called when a nested Canvas is attached in Unity UI

11 views Asked by At

I have a gameobject under a Unity 2022.3 UI hierarchy (Canvas) that I want to be draggable, so I have defined it this way:

public class InventoryItem : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler {
   ...
   public void OnBeginDrag(PointerEventData eventData) {
      ...
   }
   ...
}

This works ok, but if I add a nested Canvas to this gameobject (to be able to override its drawing sorting), it stops working and the OnBeginDrag method is not called anymore.

Why is this, and how can I make it work?

0

There are 0 answers