There is a code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class DragAndDropGame : MonoBehaviour, IBeginDragHandler, IDragHandler
{
Camera MainCamera;
void Awake()
{
MainCamera = Camera.allCameras[0];
Debug.Log(MainCamera);
}
public void OnBeginDrag(PointerEventData eventData)
{
Debug.Log("OnBeginDrag");
}
public void OnDrag(PointerEventData eventData)
{
Vector3 newPos = MainCamera.ScreenToWorldPoint(eventData.position);
newPos.z = 0;
transform.position = newPos;
}
void OnMouseDown()
{
Debug.Log("OnMouseDown");
}
}
OnMouseDown
fulfills, but the implementation ofIBeginDragHandler
, IDragHandler
- not. What can be wrong?