Game Development Reference
In-Depth Information
The UnityEvent system
The second most important improvement to Unity (in addition to the new UI ) is an
all singing, all dancing new event system.
This section is just a UI overview of the new UnityEvent system;
for a more code intensive overview, see Chapter 6 , Working with the
UI Source (it's all about the code, about that code, no tuples - a little
Meghan Trainor reference for you, now that song that is likely stuck
in your head as well!! ).
At its core, it is not much more than a weak reference manager, marshalling calls
between the input and raycasting systems and exposing these calls as events that
any delegate or control can attach to. It's also much, much more, with its extensive
extensibility framework.
For more information on what Weak Referencing is and what it
means to you, check out this great Code Project article on it:
http://bit.ly/WeakReferencing .
Raycasting
At the heart of the new Unity UI user interaction system is the use of Raycasting
to determine what UI component the user is interacting with, either via movement
(am I over a UI control?), direct interaction (click, hold, drag, release, and so on), or
combinations thereof.
Raycasting is a method of drawing a line from a single point to another
and determining whether anything got in the way or got hit by drawing
that line (known as a ray). It can either be two arbitrary points, or (as in
most cases) a line from the user's touch, click, or hover through the scene
to see whether they are interacting with anything.
For more details, check the Unity page on Raycasting here:
http://docs.unity3d.com/Manual/CameraRays.html .
In most cases, raycasting is done to a single layer in your scene
(the interactable bits) to improve performance and only interact
with interactable things on that layer.
With the UI system, these are generally UI controls on the UI layer
(the default for Unity UI controls) but this behavior can be altered if
you wish.
 
Search WWH ::




Custom Search