In this lecture, we'll look at the menu system for the Feed the Teddies Game. So let's go do that. The menu system for this game is very similar to the menu system that you implemented in the previous module for Wacky Breakout Project Increment III. As you can see, we have a HighScoreMenu that's a prefab and a PauseMenu that's a prefab. And we have MainMenu scenes and DifficultyMenu scenes in addition to our GamePlay scene. The HighScoreMenu is not something you need to be concerned about because you did a HelpMenu instead. And the PauseMenu is very similar to what you would have done in Programming Assignment III. Let's look at the behavior of the menu system, then we'll go look at the code. When we run the game, we can go to the HighScoreMenu, and see this is the current high score for this particular game for me. And I can quit back to the MainMenu. I can click the Quit button in a build so it quits the application. And if I click the Play button, I go to Easy, Medium, or Hard. I'll just pick one, and now I'll press Escape, and I can Resume or Quit. I'll resume and it goes back to gameplay, or if I press escape and quit, it goes back to the MainMenu. So obviously, there's no gameplay yet in what I'm showing you, this is just the menu system. Let's take a look at the code. We have an enumeration of the different MenuNames in the game. And we have a MenuManager that looks much like the MenuManagers we've looked at before. So, it exposes a GoToMenu method with MenuName as the parameter. If you're going to the DifficultyMenu, the SceneManager loads the DifficultyMenu scene. If you're going to the HighScoreMenu, the high scores are prefab. So, it first finds the MainMenuCanvas and hides that. So if we go to the HighScoreMenu from the MainMenu, we want to hide all those MainMenu buttons, and so on, and that's what this chunk of code does. I will admit that in the final game, we check for null for the MainMenuCanvas before we set active to false for that MainMenuCanvas, because we get the HighScoreMenu in gameplay also when the game ends, and there is no MainMenuCanvas in the gameplay scene. We then instantiate this resource by loading it, just as we do for the PauseMenu. So we're loading this prefab at runtime. Going to the MainMenu, which happens when we go back from the HighScoreMenu, or when we quit from the PauseMenu, it just loads the scene for MainMenu. And pausing the game is something we've seen before, we load that prefab resource. The MainMenu script handles the PlayButtonClick in which case, it goes to the DifficultyMenu. It handles the HighScoreButtonClick in which case, we go to the HighScoreMenu. And it handles the QuitButtonClick, which makes us quit the application. And remember, that only works in a built game. Our DifficultyMenu is interesting, for Programming Assignment III, you didn't have to actually implement any difficulty. But here, in this menu system, I've already put in place the stuff we need to do to do that. So, notice that the DifficultyMenu is an IntEventInvoker because it will invoke an IntEvent. Specifically, it will invoke the GameStartedEvent. So, we create a new GameStartedEvent object, and this is actually a piece of code from Chapter 20 in the book where I slowly built up the game. So, we actually know that IntEventInvoker actually has a dictionary of Unity events that are keyed by the EventName. So, this is sort of before I implemented that change. So by the time the game is complete, of course, I added to the dictionary, but at this point, IntEventInvoker only had one Unity event field because I didn't realize at this point that the burger had to fire two IntEvents. So, we create that object, and then we register the invoker with the GameStartedEvent and the "this" script with the EventManager. The three DifficultyMenu buttons all look remarkably similar. So, when the EasyButton is clicked, I'm going to invoke that GameStartedEvent and I'm going to say it's an easy game. So, I have a difficulty enumeration, and I can actually cast the difficulty to an Int because the default type for enumerations sort of under the covers, is actually Int. So I can cast between Int and the difficulty enumeration without any trouble. And that's good because the only kind of Unity event I can invoke is one that has an Int. And so that's why I cast it to an Int. The MediumButton starts a medium game, the HardButton starts a hard game. The HighScoreMenu has a message. And in start, it goes to check the PlayerPrefs for a High Score, and if there is a High Score stored, it sets the message text to the caption plus getting that actual value using the High Score key. But if there is no High Score yet, which is certainly the case the first time you play the game, it just says, "No games played yet." in the HighScoreMenu. There is a QuitButton under the HighScoreMenu and when we click it, we go to the MainMenu. And that works whether we're going back to the MainMenu from the MainMenu or whether we're going to the MainMenu after finishing a game. Finally, the PauseMenu, this is identical to the PauseMenu that I demonstrated in the previous module. So, when we start, in other words, we've just instantiated the PauseMenu prefab that the script is attached to. We pause the game, we set time scale to zero. If resume is clicked, we unpause the game and destroy the PauseMenu. And if the QuitButton is clicked, we unpause the game, we destroy the PauseMenu, and we go back to the MainMenu. And that's all there is to the menu system for the Feed the Teddies Game. To recap, in this lecture, we saw how to use a MenuManager to implement a slightly more complex menu system than we've done before.