Game Development Reference
In-Depth Information
You could also have several objects using the same tooltip; or even make the tooltip
dynamic and change its text/image based on the object it hovers over.
So how does this actually work then? Sure, we have this script but what does it
all mean?
Since we added the IPointerEnterHandler and IPointerExitHandler interfaces,
the following now happens:
Note: If you only add the interfaces and not the implemented methods,
your script will fail with a message like this:
Does not implement interface member UnityEngine.EventSystems.
IPointerExitHandler.OnPointerExit ( UnityEngine.
EventSystems.PointerEventData )'
To fix this, add the methods you are missing manually, or by using the
automatic method mentioned earlier.
• You have a script that implemented one of the previously mentioned events
attached to a GameObject in a scene
• When an input handler (say the StandaloneInputModule ) needs to fire an
event it will search for relevant GameObjects that implement the interface for
the event (this may be limited to those identified by raycast hits)
• If a GameObject is found to be implementing the relevant interface, it then
executes the handler method for that interface and passes the necessary data
for that event with it
Some events are managed by the Input handlers, others are managed by the Event
system itself.
All this framework does, is to make it incredibly simple to add handling for these
types of events to any script or component easily.
Building your own handlers or custom events
Now, you don't have to edit Unity's UI source code to build your own events; you
can just write your own. It is a bit of a complicated setup but if you follow the
standard, then it will be a lot easier to manage alongside Unity's UI framework
(and if you find it immensely useful you could submit it to Unity later).
 
Search WWH ::




Custom Search