只需要在对应的UGUI对象上挂个脚本,实现IPointerClickHandler(引用 using UnityEngine.EventSystems)接口,在类里面实现
public void OnPointerClick(PointerEventData eventData)
{
DoSomething();
Debug.Log("Click Me!");}
方法就可以响应你想要处理的事件了
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class BasePointer : MonoBehaviour,IPointerClickHandler {
public void OnPointerClick(PointerEventData eventData)
{
Debug.Log("Click Me!");
}
}