Is there one thing particular I have to do to get the drag handlers to work on my UI?
I’ve an EventHandler, a Canvas with a GraphicsRaycaster, and the Canvas has 2 kids, each TextMeshPro buttons. Each buttons have the TextMeshPro textual content packing containers that they arrive with, and certainly one of them additionally has an Picture baby as nicely. The buttons have the Interactable field checked.
Utilizing the next code, I do not get any debug log messages:
utilizing UnityEngine;
utilizing UnityEngine.EventSystems;
public class OnDragTest : MonoBehaviour, IBeginDragHandler, IEndDragHandler
{
public void OnBeginDrag(PointerEventData eventData)
{
Debug.Log("BEGIN");
}
public void OnEndDrag(PointerEventData eventData)
{
Debug.Log("END");
}
}
I might assume that the script must be hooked up to no matter UI factor you need to deal with the drag for, however simply to make certain I wasn’t lacking one thing I ended up including it additionally to the Canvas and the EventSystem. So now the EventSystem, the Canvas, and all scene hierarchy descendants of the Canvas all have the OnDragTest element. Nonetheless nothing.
The buttons are clickable. If I add a callback within the Button element’s OnClick, the clicking occurs and works effective.
All I would like is to deal with drag occasions. What different hoops do I’ve to leap by way of to get there?