Adding a pause screen button
While many mobile games do support controllers through Bluetooth, most, if not all, of them allow the users to control the game via just the device. Increasingly, many mobile games will include on-screen buttons or analog sticks that players can use to control their avatars. In this section, we will see just how we can implement that if we wish.
To start off, let’s build a pause menu button:
- Since we are going to be creating multiple types of on-screen controls, let’s create a panel to hold them all. From the Hierarchy view, right-click on the Canvas object and select UI | Panel. Rename the object to
On Screen Controls
. From the Inspector view, remove or disable the Image component, as we don’t need to see the image.
For this version of our controls, we will be using some 2D sprites to make it easier to tell what the various UI elements are. The sprites are included in the example code for this book if you’d...