Nextrek
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
|
//----------------------------------------------
// NGUI: Next-Gen UI kit
// Copyright © 2011-2013 Tasharen Entertainment
//----------------------------------------------
using UnityEngine;
/// <summary>
/// This script can be used to forward events from one object to another.
/// In most cases you should use UIEventListener script instead. For example:
/// UIEventListener.Get(gameObject).onClick += MyClickFunction;
/// </summary>
[AddComponentMenu("NGUI/Interaction/Forward Events")]
public class UIForwardEvents : MonoBehaviour
{
public GameObject target;
public bool onHover = false;
public bool onPress = false;
public bool onClick = false;
public bool onDoubleClick = false;
public bool onSelect = false;
public bool onDrag = false;
public bool onDrop = false;
public bool onInput = false;
public bool onSubmit = false;
public bool onScroll = false;
void OnHover (bool isOver)
{
if (onHover && target != null)
{
target.SendMessage("OnHover", isOver, SendMessageOptions.DontRequireReceiver);
}
}
void OnPress (bool pressed)
{
if (onPress && target != null)
{
target.SendMessage("OnPress", pressed, SendMessageOptions.DontRequireReceiver);
}
}
void OnClick ()
{
if (onClick && target != null)
{
target.SendMessage("OnClick", SendMessageOptions.DontRequireReceiver);
}
}
void OnDoubleClick ()
{
if (onDoubleClick && target != null)
{
target.SendMessage("OnDoubleClick", SendMessageOptions.DontRequireReceiver);
}
}
void OnSelect (bool selected)
{
if (onSelect && target != null)
{
target.SendMessage("OnSelect", selected, SendMessageOptions.DontRequireReceiver);
}
}
void OnDrag (Vector2 delta)
{
if (onDrag && target != null)
{
target.SendMessage("OnDrag", delta, SendMessageOptions.DontRequireReceiver);
}
}
void OnDrop (GameObject go)
{
if (onDrop && target != null)
{
target.SendMessage("OnDrop", go, SendMessageOptions.DontRequireReceiver);
}
}
void OnInput (string text)
{
if (onInput && target != null)
{
target.SendMessage("OnInput", text, SendMessageOptions.DontRequireReceiver);
}
}
void OnSubmit ()
{
if (onSubmit && target != null)
{
target.SendMessage("OnSubmit", SendMessageOptions.DontRequireReceiver);
}
}
void OnScroll (float delta)
{
if (onScroll && target != null)
{
target.SendMessage("OnScroll", delta, SendMessageOptions.DontRequireReceiver);
}
}
}
|
Revision |
Author |
Commited |
Message |
83
|
FMMortaroli
|
Tue 13 May, 2014 11:32:51 +0000 |
|