Adding a game pause button
At the beginning of the previous section, we briefly spoke about the in-game pause button. This button will appear at the start of a level and once pressed, the player, enemies, and bullets that have been fired will freeze in time. In this section, we will only be focusing on the visuals, just as we did with our pause screen in the previous section.
The pause button will act slightly differently from the previous buttons we have made. This time, the button will be an on-or-off-type button. The game object for this will be a toggle as it is more suited to our needs. To make a toggle
game object, do the following:
- Select the
PauseContainer
game object in the Hierarchy window, right-click it, and select UI from the drop-down list, followed by Toggle, as shown in the following screenshot:
- With the
Toggle
game object still selected in the Hierarchy window, right-click...