Creating Managers Part 2
The Audio and UI Managers
Audio Manager
Setup
I created The Audio Manager as a Singleton. It needs an Audio Source to play Voice Overs and an Audio Source to play the back ground music. I also include a default clip to use for the music to play in the background. I created a Method to play the voice over as a one shot. I then create a Method that plays the back ground music looping. Before playing the Background music I make sure that there is no other music already playing.

I then assign the need values in the Inspector.

Using The Audio Manager
The First Place that I want to use the Audio Manager is in the cutscene game event listener. I want to be able to assign music that will play in the background when cut scenes play. For example the Start cut scene has a different background music to play. Once the cutscene is complete make sure that the default background music is played.

The only One that I do not have different background music to play is the sleeping guard cutscene. I assigned all the rest of them values. By leaving the Sleeping Guards Empty it will play the default music.

The Other place that I want to use this is for the voice over triggers. Currently The triggers trigger a game event. On the Dialogue Audio Source Object I have a Unity Event Listener that Plays the Audio Clip. I am going to remove all of the Unity Event Listeners here and create a Voice Over Trigger to use.

The Voice Over Trigger I do similar to the Game Event Trigger. Instead of triggering a Game Event I Use the Audio Manager to Play the Voice Over Clip.

I add the Voice Over Trigger to the Voice Over Triggers in the Scene. I then Assign the Audio Clips to Play.

UI Manager
Setup
Just like the Game Manager and Audio Manager I created an Empty Game Object with The UI Manager Component.

I created a Singleton Behavior, Do not forget the Disallow Multiple Component

I created a method to Restart the level. Using the Screen Manager to Load the Current Active Screen. I Created A Method to quit the Application. Application.Quite Does not work in the Editor or for Web GL Builds, for the Editor I Used The Editor Is Playing, and for the Web GL Build I Opened my website.

I then used the Restart and Quit Methods of the UI Manager for the Restart and Quit Buttons in my cut scenes.

The UI Buttons Now Work.
