1. 引用using UnityEngine.EventSystems;
2.接口继承IDragHandler
3. rec.anchoredPosition :RectTrsndform的中心锚点位置(0,0,0)
4. eventData.delta :鼠标的轻微的移动值
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class movePosition : MonoBehaviour,IDragHandler{
RectTransform rec;
void Awake()
{
rec = GetComponent<RectTransform>();
}
public void OnDrag(PointerEventData eventData)
{
rec.anchoredPosition += eventData.delta;
}
void Start () {
}