Game Development Reference
In-Depth Information
6.
Save the script.
7.
Add it to the Weaponry object.
8.
In the Mouse Over component, type in the Animation state names for Clip 1
and Clip 2, being careful to type them exactly as they were named in the
Animator (Figure 10-27 ).
Figure 10-27. The state names in the Mouse Over component
If you click Play now and try to mouseover or click the Weaponry tab, nothing will happen. That is
because 2D and 3D objects must have a collider in order to catch mouse events. It doesn't matter if
they are set to Is Trigger or not.
9.
From the Components menu, Physics 2D, add a Box Collider2D to the
Weaponry sprite.
10.
Click Play, and test.
Nothing happens yet because the two 3D objects have colliders that are blocking the mouse events
from reaching the panel even though there is space between the sprites and quads. The fence
should block the mouse events where it covers the panel, but the wall should not interfere at all.
1.
Select the Stone Wall, and disable its Mesh Collider component.
2.
Click Play, and test the mouseovers and picks.
This time, the panel goes up and down with mouse enter and mouse exit events and prints the
“ouch!” message out to the console when picked.
Comment out the print line, and save the script.
3.
4.
Set up the Navigation panel to match the Weaponry panel, naming the
animation clip Navigation Up and the animation states Navigation Up and
Navigation Down .
 
Search WWH ::




Custom Search