Invisible button zones
In Chapter 2, we discussed tapping zones on the screen. Often, in mobile games, tapping anywhere on the screen will cause an event. For example, many times when you select outside of a pop-up window, it will close. Other examples are when you can tap on the left or right side of the screen to move a character back and forth. Tapping on areas of the screen may not seem like a button implementation, but it actually is! The buttons are just invisible.
Let’s explore the first scenario. If you review the Close Panel Example
GameObject of the Chapter9
scene, you will see a Panel that appears when an info button is pressed, closes when the close button is pressed, and also closes when the area outside of the Panel is pressed. This is accomplished by putting a large, invisible button behind the Panel. For it to work appropriately, it needs to be in front of the info button (blocking raycast to it).
Figure 9.15: Close Panel Example...