Image를 마우스로 드래그할 수 있는 이벤트를 구현하기 위해 UI EventHandler 추가
This commit is contained in:
26
Assets/Scripts/UI/UI_EventHandler.cs
Normal file
26
Assets/Scripts/UI/UI_EventHandler.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
|
||||
public class UI_EventHandler : MonoBehaviour, IBeginDragHandler, IDragHandler
|
||||
{
|
||||
public Action<PointerEventData> OnBeginDragHandler = null;
|
||||
public Action<PointerEventData> OnDragHandler = null;
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
if (OnBeginDragHandler != null)
|
||||
{
|
||||
OnBeginDragHandler.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
if (OnDragHandler != null)
|
||||
{
|
||||
OnDragHandler.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user