[Unity] drag & drop

박호준·2022년 2월 15일
0

Unity

목록 보기
15/17

Textur Shape -> Cube // Apply

  • IEndDragHandler : 아무데서나 놓아도 호출
  • IDropHandler : 마우스가 드래그 중인 객체 안에서 놓으면 호출
using UnityEngine.EventSystems;
public class dragdrop : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IDropHandler // 우클릭 빠른작업 리펙토링 , interfacer구
{
    public void OnBeginDrag(PointerEventData eventData)
    {
        Debug.Log("Begin Drag");
    }

    public void OnDrag(PointerEventData eventData)
    {
        transform.position = eventData.position;
        Debug.Log("Drag");
    }

    public void OnDrop(PointerEventData eventData)
    {
        Debug.Log("Drop");

    }

    public void OnEndDrag(PointerEventData eventData)
    {
        Debug.Log("End Drag");

    }
}
profile
hopark

0개의 댓글