yyl
昨天 5d3366f2e0f687995eb7ad2107c4379fe7acd4e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//--------------------------------------------------------
//    [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;
        }
 
 
    }