Week 7: Game Over Menu - Designing an UI
Hello, in this post i will show you how to do a game over menu. Since the last time our group have added the dead condition. Player will die once the plane hits the ground or be killed by the boss. First thing we need to do is open photoshop, create a image that says GAME OVER over a black screen and this is it. Then we open Unity and create a new Scene called gameOver in the scene folder. In the current version of the game this means that we have 5 scenes in this folder: BossFight, Flying, GameOver, LevelSelector and Main Menu. Nevermind the "Boss" scene in the screen shot, it was a test scene.
![](https://static.wixstatic.com/media/aa724d_65d55118d52d477fba733e55e9ce76be.png/v1/fill/w_800,h_214,al_c,q_85,enc_auto/aa724d_65d55118d52d477fba733e55e9ce76be.png)
Then in the blank scene add a new canvas in the Hierarchy. This is done with Right click -> UI -> Canvas
![](https://static.wixstatic.com/media/aa724d_77830c8d1db74d949c446e916ce4561d.png/v1/fill/w_980,h_551,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/aa724d_77830c8d1db74d949c446e916ce4561d.png)
Then again Right click -> UI -> Image and then drag it into the Image into the Canvas and then in the Inspector drag the Game Over image we created earlier over Image (script) -> Source Image and then resize it to fit the screen
![](https://static.wixstatic.com/media/aa724d_53a104bed1b6409e84b342857391d341.png/v1/fill/w_400,h_599,al_c,q_85,enc_auto/aa724d_53a104bed1b6409e84b342857391d341.png)
After that we must create two buttons called Retry and Main Menu. Under both of them in the Hierarchy tab you will have two text tabs. Fill both of them with text such as Retry and Main Menu for each.
![](https://static.wixstatic.com/media/aa724d_d7cfd789af7f42d7adb386d60c9dfdca.png/v1/fill/w_374,h_337,al_c,q_85,enc_auto/aa724d_d7cfd789af7f42d7adb386d60c9dfdca.png)
I made the buttons to be blue and become white when highlighted. Then to make these buttons make something we have to write really easy script. Create an Empty Game Object and add c# script called something like Game Over menu. When you open the script remove Start() and Update() functions and create two new functions which i called BackMenu and Retry. And then we only have to load new Scenes in these two methods.
![](https://static.wixstatic.com/media/aa724d_91d49a2a6afc437290548024f302576e.png/v1/fill/w_980,h_551,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/aa724d_91d49a2a6afc437290548024f302576e.png)
Only one thing left - make the buttons do what you want. Back to hierarchy and mark the Retry Button. In the end of the inspector there will have a window that says On Click(). Click on the plus in the bottom right end, drag the GameObject with the attached script over it and then on RuntimeOnly select 'NameOfScript'.Retry.
![](https://static.wixstatic.com/media/aa724d_f066a1aa251044e988c62fd905b4b48c.png/v1/fill/w_367,h_102,al_c,q_85,enc_auto/aa724d_f066a1aa251044e988c62fd905b4b48c.png)
When you do the same for the other button we should have finished and working Game Over screen.
![](https://static.wixstatic.com/media/aa724d_9effdc06fe9242b4b54a7c47b257d448.png/v1/fill/w_323,h_359,al_c,q_85,enc_auto/aa724d_9effdc06fe9242b4b54a7c47b257d448.png)