| //-------------------------------------------------------- | 
| //    [Author]:           玩个游戏 | 
| //    [  Date ]:           Monday, July 31, 2017 | 
| //-------------------------------------------------------- | 
| using UnityEngine; | 
| using System.Collections; | 
| using UnityEngine.EventSystems; | 
| using UnityEngine.Events; | 
| using System; | 
|   | 
|     public class PointerDownUp : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerClickHandler | 
|     { | 
|   | 
|         [SerializeField] | 
|         Action m_OnPointerDown; | 
|   | 
|         [SerializeField] | 
|         Action m_OnPointerUp; | 
|   | 
|         [SerializeField] | 
|         Action m_OnPointerClick; | 
|   | 
|         public void OnPointerUp(PointerEventData eventData) | 
|         { | 
|             m_OnPointerUp?.Invoke(); | 
|         } | 
|   | 
|         public void OnPointerDown(PointerEventData eventData) | 
|         { | 
|             m_OnPointerDown?.Invoke(); | 
|         } | 
|   | 
|         public void OnPointerClick(PointerEventData eventData) | 
|         { | 
|             m_OnPointerClick?.Invoke(); | 
|         } | 
|   | 
|         public void AddPointerDownListener(Action _action) | 
|         { | 
|             m_OnPointerDown += _action; | 
|         } | 
|   | 
|         public void AddPointerUpListener(Action _action) | 
|         { | 
|             m_OnPointerUp += _action; | 
|         } | 
|   | 
|         public void AddPointerClickListener(Action _action) | 
|         { | 
|             m_OnPointerClick += _action; | 
|         } | 
|   | 
|         public void RemoveAllPointerDownListeners() | 
|         { | 
|             m_OnPointerDown = null; | 
|         } | 
|   | 
|         public void RemoveAllPointerUpListeners() | 
|         { | 
|             m_OnPointerUp = null; | 
|         } | 
|   | 
|         public void RemoveAllPointerClickListeners() | 
|         { | 
|             m_OnPointerClick = null; | 
|         } | 
|   | 
|   | 
|     } |