Project 1C: Barrel Bouncer (UI & Scoring)

Part 1: The Main Menu

Creating a New Scene

For most of this project, you’ve been working with a single scene. However, as we saw in our last lecture, there are several reasons why you might want to use multiple scenes in a compeleted game or application. One such reason is to have a starting scene with a main menu to welcome the user and give them access to various settings, instructions, and other functionality before they begin playing the game. In this section, you will be building out a basic main menu scene for Barrel Bouncer.

To begin, go to your menu bar and click on File -> New Scene. Then save your scene with a new name, like “StartScene” or “MainMenu”. Finally, open up your build settings (File -> Build Settings) and add your new scene to the build. You should also add your main gameplay scene to the build if it isn’t already. Make sure that the main menu is listed first (i.e. at index 0) or drag it up to switch the order if it isn’t. It is important that all your scenes are listed in the build; otherwise they won’t work with Unity’s scene management and you won’t be able to load them from other scenes. Additionally, the first scene listed is the one that is automatically loaded when the user starts the game in a built application.

Building the UI

Next, you should create a screen-space UI for the main menu. Below are some screenshots of what your final result may look like:

An image of a sample main menu UI

Below are the main components of your UI for this scene:

Background Music

It is also common to have some background music in a welcome scene. Find a music track of your choice and import the file into Unity. Next, create a new GameObject called “Audio Manager”, add an Audio Source component to it, drag the soundtrack you imported into the AudioClip reference, and make sure the Play On Awake and Loop checkboxes are selected. This will allow the sound to automatically begin playing when the scene starts and also keep repeating the song once it ends. Additionally, you should leave the spatial blend at 2D, since it will not be playing from any specific 3D coordinate in our scene, but rather just provide us with some ambient music.

You should also add a script to your audio manager to give it the following functionality:

Previous Section | Go Home | Next Section