Examples
We will continue to work on the UI we have been building for the last two chapters. To help organize the project, duplicate the Chapter3
scene that you created in the last chapter; it will automatically be named as Chapter4
.
Showing and hiding pop-up menus with keypress
So far, we have made two panels that we plan on making pop-ups: Pause Panel
from Chapter 2, Canvases, Panels, and Basic Layout and Inventory Panel
from Chapter 3, Automatic Layouts. Right now they are both visible in the scene (even though Pause Panel
is hidden behind the Inventory Panel
). We want them to pop up when we press specific p and i on the keyboard. For demonstration purposes, we'll access the keyboard keys differently for each panel.
Remember that both of these panels have Canvas Group components on them. These components will allow us to easily access the panels' alpha, intractable, and blocks raycasts properties.
Using KeyCode with the Inventory Panel
Let's begin with the Inventory Panel
. We want the panel...