| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: 第二世界 |
| | | // [Author]: 玩个游戏 |
| | | // [ Date ]: Monday, July 31, 2017 |
| | | //-------------------------------------------------------- |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using UnityEngine.EventSystems; |
| | | using UnityEngine.Events; |
| | | |
| | | namespace vnxbqy.UI |
| | | { |
| | | using System; |
| | | |
| | | public class PointerDownUp : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerClickHandler |
| | | { |
| | | |
| | | [SerializeField] |
| | | UIEvent m_OnPointerDown; |
| | | public UIEvent onPointerDown { get { return m_OnPointerDown; } } |
| | | Action m_OnPointerDown; |
| | | |
| | | [SerializeField] |
| | | UIEvent m_OnPointerUp; |
| | | public UIEvent onPointerUp { get { return m_OnPointerUp; } } |
| | | Action m_OnPointerUp; |
| | | |
| | | [SerializeField] |
| | | UIEvent m_OnPointerClick; |
| | | public UIEvent onPointerClick { |
| | | get { |
| | | return m_OnPointerClick; |
| | | } |
| | | } |
| | | Action m_OnPointerClick; |
| | | |
| | | public void OnPointerUp(PointerEventData eventData) |
| | | { |
| | | if (onPointerUp != null) |
| | | { |
| | | onPointerUp.Invoke(); |
| | | } |
| | | m_OnPointerUp?.Invoke(); |
| | | } |
| | | |
| | | public void OnPointerDown(PointerEventData eventData) |
| | | { |
| | | if (onPointerDown != null) |
| | | { |
| | | onPointerDown.Invoke(); |
| | | } |
| | | m_OnPointerDown?.Invoke(); |
| | | } |
| | | |
| | | public void OnPointerClick(PointerEventData eventData) |
| | | { |
| | | if (onPointerClick != null) |
| | | { |
| | | onPointerClick.Invoke(); |
| | | } |
| | | m_OnPointerClick?.Invoke(); |
| | | } |
| | | |
| | | public void AddPointerDownListener(UnityAction _action) |
| | | public void AddPointerDownListener(Action _action) |
| | | { |
| | | if (onPointerDown != null) |
| | | { |
| | | onPointerDown.AddListener(_action); |
| | | } |
| | | m_OnPointerDown += _action; |
| | | } |
| | | |
| | | public void AddPointerUpListener(UnityAction _action) |
| | | public void AddPointerUpListener(Action _action) |
| | | { |
| | | if (onPointerUp != null) |
| | | { |
| | | onPointerUp.AddListener(_action); |
| | | } |
| | | m_OnPointerUp += _action; |
| | | } |
| | | |
| | | public void AddPointerClickListener(UnityAction _action) |
| | | public void AddPointerClickListener(Action _action) |
| | | { |
| | | if (onPointerClick != null) |
| | | { |
| | | onPointerClick.AddListener(_action); |
| | | } |
| | | m_OnPointerClick += _action; |
| | | } |
| | | |
| | | public void RemoveAllPointerDownListeners() |
| | | { |
| | | if (onPointerDown != null) |
| | | { |
| | | onPointerDown.RemoveAllListeners(); |
| | | } |
| | | m_OnPointerDown = null; |
| | | } |
| | | |
| | | public void RemoveAllPointerUpListeners() |
| | | { |
| | | if (onPointerUp != null) |
| | | { |
| | | onPointerUp.RemoveAllListeners(); |
| | | } |
| | | m_OnPointerUp = null; |
| | | } |
| | | |
| | | public void RemoveAllPointerClickListeners() |
| | | { |
| | | if (onPointerClick != null) |
| | | { |
| | | onPointerClick.RemoveAllListeners(); |
| | | } |
| | | m_OnPointerClick = null; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |