UGUI拖动事件

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_15267341/article/details/90756995
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class testt : MonoBehaviour, IDragHandler, IEndDragHandler, IScrollHandler, IPointerDownHandler
{
    public void OnDrag(PointerEventData eventData)
    {
        print("OnDrag");
        print(eventData.pointerDrag);  //开始拖动的对象
        print(eventData.pointerEnter);  //当前鼠标下面的UI对象
    }

    public void OnEndDrag(PointerEventData eventData)
    {
        print("OnEndDrag");
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        print("OnPointerDown");
        
    }

    public void OnScroll(PointerEventData eventData) //鼠标在UI上面滚动时会触发
    {
        print("OnScroll");
    }

    // Use this for initialization
    void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}

 

展开阅读全文

没有更多推荐了,返回首页