Unity笔记之鼠标拖拽UI

需求:拖拽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("结束拖拽");
            
        }
    }
}

其实就是继承事件系统的接口,然后实现就好了

posted @ 2022-01-17 10:45  一世癫狂  阅读(18)  评论(0)    收藏  举报  来源