| | |
| | | using UnityEngine.Events; |
| | | using UnityEngine.EventSystems; |
| | | using System.Collections.Generic; |
| | | using System; |
| | | |
| | | namespace vnxbqy.UI |
| | | { |
| | | |
| | | [RequireComponent(typeof(RectTransform))] |
| | | public class FakeButton : MonoBehaviour, IPointerClickHandler, IPointerDownHandler, IPointerUpHandler, IDragHandler |
| | | { |
| | | RectTransform m_RectTransform; |
| | | public RectTransform rectTransform { get { return m_RectTransform ?? (m_RectTransform = this.transform as RectTransform); } } |
| | | |
| | | UIEvent m_OnClick = new UIEvent(); |
| | | Action m_OnClick; |
| | | |
| | | public void AddListener(UnityAction _callBack) |
| | | public void AddListener(Action action) |
| | | { |
| | | m_OnClick.AddListener(_callBack); |
| | | m_OnClick += action; |
| | | } |
| | | |
| | | public void RemoveAllListeners() |
| | | { |
| | | m_OnClick.RemoveAllListeners(); |
| | | m_OnClick = null; |
| | | } |
| | | |
| | | public void OnPointerUp(PointerEventData eventData) |
| | |
| | | |
| | | public void OnPointerClick(PointerEventData eventData) |
| | | { |
| | | m_OnClick.Invoke(); |
| | | m_OnClick?.Invoke(); |
| | | PassEvent(eventData, ExecuteEvents.submitHandler); |
| | | PassEvent(eventData, ExecuteEvents.pointerClickHandler); |
| | | } |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |