โดยการ using UnityEngine.EventSystems;
จากนั้นทำการ Inherits IBeginDragHandler, IDragHandler, IEndDragHandler
แล้วทำการ Implement Function ครับ
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class UIDragAndDrop : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
private GameObject dragItem;
private Vector3 startPosition = Vector3.zero;
public void OnBeginDrag(PointerEventData eventData)
{
dragItem = null;
startPosition = transform.position;
}
public void OnDrag(PointerEventData eventData)
{
transform.position = Input.mousePosition;
}
public void OnEndDrag(PointerEventData eventData)
{
dragItem = gameObject;
transform.position = startPosition;
}
}
ปล. มีอะไรแนะนำได้นะครับ
NO GAME NO DREAM !!!!