[Video][Game Making Tutorial 7] Main Menu, Pause Menu, Music, Save, Load!

 

This tutorial was really exciting to make. I hope you guys learn as much as I think you will – because it’s really special, that’s why it’s long.

 

Music used for this Tutorial

 

So, what did we do here? Bullet points incoming:

 

  • Using UnityEngine.UI : When you want to use some special function in Unity (or an Asset you downloaded), you call it with “using”. This gives your script access to a non-default Unity/Asset library of functions.

 

  • Buttons inside Canvases: These buttons will allow you to call any Public Void you have in any Game Object, as long as that game object is dragged and dropped into the OnClick() area. It’s a preset script at work and it’s very nice and intuitive to use. You can use anything as a button. Images of any kind, as long as you place them in the area that’s called “Image (Script)”.

 

  • Mute: Your Main Camera has an AudioListener attached to it. If you set its volume to Zero, you’re effectively muting every single sound in your scene.

 

  • Music: To add music, you must create an empty GameObject and attach an AudioSource to it. Then drag and drop an mp3/Wav/Ogg file to your Assets/Audio folder, finally drag it and set it to Loop. Done, you now have music in your scene.

 

  • Pause Logic: So, if my game is Paused, Time is stopped. (Time.timeScale = 0), also my Pause Menu is showing (PauseMenu.SetActive(true)) and anytime the player hits the Pause Key again, it’ll go back to normal (revert the changes in an ELSE IF). It is simple but sometimes it gets weird, so that’s why on Start you have to say Pause = false. It’s really important to. This can have issues with other times when you want to Pause the game without showing the Pause menu, but as a general rule for simple games, this Pause mechanism is 100% fine.

 

  • Save/Load Game: For saving, simply, PlayerPrefs can store where the player was, which scene, how much HP, etc. I’m showcasing one of those, SetInt with the Scene’s integer Index so you can load it through GetInt in the Load method.

 

Questions? Suggestions? Forums, Youtube, Email as always! Or comment here. Thanks for watching and share to your friends!

Share

One Response to “[Video][Game Making Tutorial 7] Main Menu, Pause Menu, Music, Save, Load!

Leave a Reply

Your email address will not be published. Required fields are marked *