首页 > 代码库 > UGUI的9个重要回调函数

UGUI的9个重要回调函数

using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;

//句柄
public class ButtonFuc : MonoBehaviour,
IPointerEnterHandler,IPointerExitHandler,//进入,离开
IPointerDownHandler,IPointerUpHandler,//按下抬起
IPointerClickHandler,//点击
IBeginDragHandler,IDragHandler,IEndDragHandler//拖拽
{
    public void OnPointerEnter (PointerEventData eventData)
    {
        Debug.Log ("Enter");
    }

    public void OnPointerExit(PointerEventData eventData)
    {
        Debug.Log ("Exit");
    }

    public void OnPointerDown (PointerEventData eventData)
    {
        Debug.Log ("Down");
    }

    public void OnPointerUp (PointerEventData eventData)
    {
        Debug.Log ("Up");
    }

    public void OnPointerClick (PointerEventData eventData)
    {
        Debug.Log ("Click");
    }

    public void OnBeginDrag (PointerEventData eventData)
    {
        Debug.Log ("BeginDrag");
    }

    public void OnDrag (PointerEventData eventData)
    {
        Debug.Log ("Drag");
    }

    public void OnEndDrag (PointerEventData eventData)
    {
        Debug.Log ("EndDrag");
    }
}

 

UGUI的9个重要回调函数