-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathUIEventListener.cs
179 lines (141 loc) · 2.78 KB
/
UIEventListener.cs
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
using UnityEngine;
[AddComponentMenu("NGUI/Internal/Event Listener")]
public class UIEventListener : MonoBehaviour
{
public delegate void VoidDelegate(GameObject go);
public delegate void BoolDelegate(GameObject go, bool state);
public delegate void FloatDelegate(GameObject go, float delta);
public delegate void VectorDelegate(GameObject go, Vector2 delta);
public delegate void ObjectDelegate(GameObject go, GameObject obj);
public delegate void KeyCodeDelegate(GameObject go, KeyCode key);
public object parameter;
public VoidDelegate onSubmit;
public VoidDelegate onClick;
public VoidDelegate onDoubleClick;
public BoolDelegate onHover;
public BoolDelegate onPress;
public BoolDelegate onSelect;
public FloatDelegate onScroll;
public VoidDelegate onDragStart;
public VectorDelegate onDrag;
public VoidDelegate onDragOver;
public VoidDelegate onDragOut;
public VoidDelegate onDragEnd;
public ObjectDelegate onDrop;
public KeyCodeDelegate onKey;
public BoolDelegate onTooltip;
private void OnSubmit()
{
if (onSubmit != null)
{
onSubmit(base.gameObject);
}
}
private void OnClick()
{
if (onClick != null)
{
onClick(base.gameObject);
}
}
private void OnDoubleClick()
{
if (onDoubleClick != null)
{
onDoubleClick(base.gameObject);
}
}
private void OnHover(bool isOver)
{
if (onHover != null)
{
onHover(base.gameObject, isOver);
}
}
private void OnPress(bool isPressed)
{
if (onPress != null)
{
onPress(base.gameObject, isPressed);
}
}
private void OnSelect(bool selected)
{
if (onSelect != null)
{
onSelect(base.gameObject, selected);
}
}
private void OnScroll(float delta)
{
if (onScroll != null)
{
onScroll(base.gameObject, delta);
}
}
private void OnDragStart()
{
if (onDragStart != null)
{
onDragStart(base.gameObject);
}
}
private void OnDrag(Vector2 delta)
{
if (onDrag != null)
{
onDrag(base.gameObject, delta);
}
}
private void OnDragOver()
{
if (onDragOver != null)
{
onDragOver(base.gameObject);
}
}
private void OnDragOut()
{
if (onDragOut != null)
{
onDragOut(base.gameObject);
}
}
private void OnDragEnd()
{
if (onDragEnd != null)
{
onDragEnd(base.gameObject);
}
}
private void OnDrop(GameObject go)
{
if (onDrop != null)
{
onDrop(base.gameObject, go);
}
}
private void OnKey(KeyCode key)
{
if (onKey != null)
{
onKey(base.gameObject, key);
}
}
private void OnTooltip(bool show)
{
if (onTooltip != null)
{
onTooltip(base.gameObject, show);
}
}
public static UIEventListener Get(GameObject go)
{
UIEventListener uIEventListener = go.GetComponent<UIEventListener>();
if (uIEventListener == null)
{
uIEventListener = go.AddComponent<UIEventListener>();
}
return uIEventListener;
}
}