Drag element in Unity with IDragHandler

using UnityEngine;
using UnityEngine.EventSystems;


public class DragUI : MonoBehaviour, IDragHandler
{
    void IDragHandler.OnDrag(PointerEventData eventData)
    {
        transform.position = new Vector3(eventData.position.x, eventData.position.y,0f);
 
    }
}
Scroll to Top