54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
#nullable enable
|
|
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
namespace UVC.UI.List
|
|
{
|
|
/// <summary>
|
|
/// 개별 드래그 가능한 아이템의 UI 컴포넌트
|
|
/// 드래그 동작과 시각적 피드백을 담당
|
|
/// </summary>
|
|
public class DraggableItem : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
|
{
|
|
// 이벤트
|
|
public Action<PointerEventData>? OnBeginDragEvent;
|
|
public Action<PointerEventData>? OnDragEvent;
|
|
public Action<PointerEventData>? OnEndDragEvent;
|
|
|
|
/// <summary>
|
|
/// 드래그 시작 시 호출
|
|
/// </summary>
|
|
public void OnBeginDrag(PointerEventData eventData)
|
|
{
|
|
OnBeginDragEvent?.Invoke(eventData);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 드래그 중 호출
|
|
/// </summary>
|
|
public void OnDrag(PointerEventData eventData)
|
|
{
|
|
// 이벤트 발생
|
|
OnDragEvent?.Invoke(eventData);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 드래그 종료 시 호출
|
|
/// </summary>
|
|
public void OnEndDrag(PointerEventData eventData)
|
|
{
|
|
// 이벤트 발생
|
|
OnEndDragEvent?.Invoke(eventData);
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
// 이벤트 구독 해제
|
|
OnBeginDragEvent = null;
|
|
OnDragEvent = null;
|
|
OnEndDragEvent = null;
|
|
}
|
|
}
|
|
}
|