Game Development Reference
In-Depth Information
Objective complete - mini debriefing
We just created a menu window, which can be opened by pressing the M key and closed by
clicking on the x button at the top-right corner of the menu window. We also have our char-
acter texture nicely placed inside our menu window. Next, we made this window draggable
and made sure it is always on the screen by using the following code:
_windowRect.x = Mathf.Clamp(_windowRect.x, 0.0f,
Screen.width - _windowRect.width);
_windowRect.y = Mathf.Clamp(_windowRect.y, 0.0f,
Screen.height - _windowRect.height);
Basically, we set the minimum limit of our window in the x position to 0 and the maxim-
um to the screen width subtracted by the window width; we also set the minimum limit of
y position to 0 and the maximum to the screen height subtracted by the window height.
We will see this result when we click on Play the game and try to drag this window off the
screen. Lastly, we created a tab that can be clicked to change to a different page.
Search WWH ::




Custom Search