Drag And Drop

Hey, I have an issue with my drag and drop system code please look over it and reply with any way to fix it

My Code:
```csharp
**using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class DragAndDrop : MonoBehaviour, IPointerDownHandler, IBeginDragHandler, IEndDragHandler, IDragHandler
{

public RectTransform rect;

private void OnDrag(){
    rect.anchoredPosition += eventData.delta;
}

private void OnBeginDrag(){
    Debug.Log("Drag Started");
}

private void OnEndDrag(){
    Debug.Log("Drag Finished");
}

private void OnPointerDown(){
    Debug.Log("Object Clicked");
}

}**
```
Errors:
Assets\Assets\Scripts\DragAndDrop.cs(6,100): error CS0535: ‘DragAndDrop’ does not implement interface member ‘IDragHandler.OnDrag(PointerEventData)’

Assets\Assets\Scripts\DragAndDrop.cs(6,83): error CS0535: ‘DragAndDrop’ does not implement interface member ‘IEndDragHandler.OnEndDrag(PointerEventData)’

Assets\Assets\Scripts\DragAndDrop.cs(6,64): error CS0535: ‘DragAndDrop’ does not implement interface member ‘IBeginDragHandler.OnBeginDrag(PointerEventData)’

Assets\Assets\Scripts\DragAndDrop.cs(6,43): error CS0535: ‘DragAndDrop’ does not implement interface member ‘IPointerDownHandler.OnPointerDown(PointerEventData)’

These errors are super clear… you have an OnDrag() but not the signature it’s looking for, one that accepts a PointerEventData. That means … wait for it … you’re not implementing the interface!

Just use right-click implement interface.

1 Like