In my previous post I created a game over screen, today I create a main menu screen and make the play button active. Similar with the game over screen, create a new canvas and called Main Menu. In this canvas, add a button and rename it to “Play”. And change its text to Play also.
Then go to LogicScript to create a variable called mainMenu in gameObject variable type. And duplicate the gameOver function, just change the name to startGame() and the game object used in this function is mainMenu and set it active to false. That means the Main Menu will disappear after clicking the play button.
Next is go to the Logic Manager game object and drag the Main Menu canvas into the Main Menu of Logic Manager.
And in the Onclick() of Play button call the startGame() function.
The Main Menu disappears after clicking the play button, but I have another problem that when the player dies and the gameOver on the screen appears, after clicking the “Play Again” button, it restarts the game and the “Play” button appears on the screen again. That means the player has to click twice to replay the game, which is not good. I will try to fix that later.
No Responses