需求:拖拽UI在屏幕上动。
using System;
namespace ZXL
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class ImageDrap : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
public void OnBeginDrag(PointerEventData eventData)
{
// Debug.Log("开始拖拽");
}
public void OnDrag(PointerEventData eventData)
{
}
public void OnEndDrag(PointerEventData eventData)
{
// Debug.Log("结束拖拽");
}
}
}
其实就是继承事件系统的接口,然后实现就好了