using UnityEngine; using UnityEngine.EventSystems; public class DragImage : MonoBehaviour,IDragHandler,IBeginDragHandler,IEndDragHandler { public bool isDrag; public void OnBeginDrag(PointerEventData eventData) { GameObject draggedObject = eventData.pointerDrag; if (draggedObject != null && draggedObject.name == gameObject.name) { isDrag = true; } } public void OnDrag(PointerEventData eventData) { GameObject draggedObject = eventData.pointerDrag; if (draggedObject != null && draggedObject.name == gameObject.name) { isDrag = true; } } public void OnEndDrag(PointerEventData eventData) { GameObject draggedObject = eventData.pointerDrag; if (draggedObject != null && draggedObject.name == gameObject.name) { isDrag = false; } } }