Game Development Reference
In-Depth Information
A word about parameter types
It is worth noting that at present, Unity only supports the
C#
base types
(
bool
,
string
,
int
, and
float
) and Unity types (GameObject, and so
on) as parameter types with UnityEvents.
See this video at the 10:30 timestamp for more details on the supported
You can have up to four parameters in a single method with the current version of
the
UnityEvent
class at present but you can extend that, if you wish, in the source
code (see the
Getting access to the source
section later in this chapter)
Built-in event interfaces
For the UI system, Unity has built a horde of event types and interfaces to support
these events, ready to use, straight out of the box. Each of these is implicitly
implemented in the Input handlers to ensure all the events occur at the right time
depending on user input.
The events that are currently available in Unity 4.6 broken down in to their respective
groups are as follows: (which could change over time):
The Pointer Events:
•
IPointerEnterHandler
: This occurs when a cursor (for example a mouse
cursor) enters the
Rect Transform
area of a UI object
•
IPointerExitHandler
: This occurs when a cursor leaves the
Rect Transform
area of a UI object
•
IPointerDownHandler
: This occurs when input presses on a selectable UI
control (for example, a button)
•
IPointerUpHandler
: This occurs when input is released on a selectable
UI control
•
IPointerClickHandler
: This occurs when input clicks (presses and releases)
on a selectable UI control