So I have been trying to make a draggable object for my inventory, and here is what I have so far
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class DragDrop : MonoBehaviour, IPointerDownHandler, IBeginDragHandler, IEndDragHandler, IDragHandler
{
private RectTransform rectTransform;
private void Awake()
{
rectTransform = GetComponent<RectTransform>();
}
public void OnPointerDown(PointerEventData eventData)//This funciton (plus IPointerDownHandler in the class section) detects when the mouse clicks on the gameObject this is attached to
{
throw new System.NotImplementedException();
}
public void OnBeginDrag(PointerEventData eventData)
{
throw new System.NotImplementedException();
}
public void OnDrag(PointerEventData eventData)
{
throw new System.NotImplementedException();
rectTransform.anchoredPosition += eventData.delta; //Moves the item as it is being dragged (delta is the amount that the mouse moved since the previous frame)
}
public void OnEndDrag(PointerEventData eventData)
{
throw new System.NotImplementedException();
}
void Start()
{
}
void Update()
{
}
}
However when I try to play it, it keeps erroring out –
NotImplementedException: The method or operation is not implemented.
DragDrop.OnDrag (UnityEngine.EventSystems.PointerEventData eventData) (at Assets/DragDrop.cs:27) –
I have tried looking into it, and I have added the Hierarchy EventSystem, but I haven’t messed with it. I also have an image component on my object as that is apparently required. Also on my Canvas I have a Graphic Raycaster component if that is needed.
So what am I doing wrong/need yet?
Thanks!