Framework 1: Mission Fail Menu
Creating a menu to restart and return to main menu
Menus are an important part of game play. They give the players a sense of feedback which allows them to transverse the game without being confused. In this update, we will be implementing a revised Game Over screen along with available menu buttons.
Creating the Game Over Screen
Starting with the Image, I drew everything within Adobe Illustrator, but any program is possible and even some assets from the Unity asset store is also ok. I saved everything as a PNG file (basically PNG provides a transparent Background) and import everything into Unity.
Once imported, using the 2D sprite Editor, slice the image. (I will provide a more detailed article about sprite Editor in a later date) Hit Apply and within the Canvas game object, create UI images and place them according to the desired layout. In this case my only image is the “Mission Failed” object. The Respawn and Main Menu are both Button Components.
For convenience sake I made both buttons a child of the Image “Mission Failed” component. That way, I can just call one object instead of 3 separate objects.
Since we are working with the Canvas component, the Game Over sequence is definitely part of the UI elements. Therefore in the UI Manager script is where we are going to be triggering the on and off.
First create a handle for the game object. Then in the “Start” method, set the game over menu to false. That way, every time the game starts, by default the game over menu would be hidden.
We are now going to be creating a public method, since I was following the online courses from GameDevHQ, we have already created a perfect public method called “Game Over.” In this method, we are going to insert the Game Over object and set it back to true.
The final result is, every time we trigger the game over method, the new game over scene would pop up!