Hello ,I am KitStar
- 比较简单了,是个基本的父类。就几段,所以老规矩上脚本吧。
public abstract class UIEventManagers : MonoBehaviour ,IPointerClickHandler,IPointerDownHandler,IPointerEnterHandler,IPointerExitHandler,IPointerUpHandler{
public UnityEvent onPointerDown;
public UnityEvent onPointerUp;
public UnityEvent onPointerEnter;
public UnityEvent onPointerClick;
public UnityEvent onPointerExit;
protected virtual void OnPointerClick(PointerEventData eventData)
{
onPointerClick.Invoke();
}
protected virtual void OnPointerExit(PointerEventData eventData)
{
onPointerExit.Invoke();
}
protected virtual void OnPointerEnter(PointerEventData eventData)
{
onPointerEnter.Invoke();
}
protected virtual void OnPointerUp(PointerEventData eventData)
{
onPointerUp.Invoke();
}
protected virtual void OnPointerDown(PointerEventData eventData)
{
onPointerDown.Invoke();
}
# region .
void IPointerClickHandler.OnPointerClick(PointerEventData eventData)
{
OnPointerClick(eventData);
}
void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
{
OnPointerDown(eventData);
}
void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData)
{
OnPointerEnter(eventData);
}
void IPointerExitHandler.OnPointerExit(PointerEventData eventData)
{
OnPointerExit(eventData);
}
void IPointerUpHandler.OnPointerUp(PointerEventData eventData)
{
OnPointerUp(eventData);
}
#endregion .
}
2. 再写一些脚本。继承这个,然后丰富自己的功能吧