-
Book Overview & Buying
-
Table Of Contents
Creating E-Learning Games with Unity
By :
To process whether any of the preceding elements have been clicked or not by the mouse pointer, we have to manually program the handling of this event. Luckily for us, since these components are attached to a GameObject (which inherits from MonoBehavior), we can use mouse events that MonoBehavior provides.
Whenever the mouse pointer is clicked while the pointer is over the top of a GameObject, the OnMouseDown callback is invoked. With this, we can trap these button clicks and respond accordingly:
void OnMouseDown() { // insert code here } A second callback method is called whenever the mouse pointer moves onto a GameObject. This function is a convenient way to handle the highlighting of the GUI elements when they are selected or browsed:
void OnMouseOver() { // insert code here } A final callback method is called whenever the mouse leaves from over the top of a GameObject. This is the complement...
Change the font size
Change margin width
Change background colour