Using AudioManager to Manage the Audio Effect- Game Dev Series 118

Objective: manage most of the sound effect by using AudioManager.

By using AudioManager singleton to manage the audio effects, would be easy and clear to separate the timing of calling these sound to play.
In this article, I would shortly demonstrate how to use AudioManager singleton in game.

Create AudioManager

As usual, create an empty object and a script called “AudioManager”.
And you will need an Audio Source component in this gameobject.

Create a singleton patten to AudioManager script. Then, we can make it works.

Import audio clips to script

Let’s create the sound effect of open the shop screen.
Create an AudioClip variable to store the sound clip.

Then also create an AudioSource variable, then get the reference in Start().

Now back to Editor to drag in the “Shop Open” sound clip.

Call and play

Next create a public method to play this clip.
Make sure locate the right audio clip before playing it.

And also you need to adjust the volume of this AudioSource and disable “Play On Awake”.
Once done, we can call this method from the script of shop.

With this, when Player enter the shop and open the shop menu, you should hear the sound clip that we imported.

Easy to replace the clip

If you need another sound effect, just create another variable and drag the file in.

And also create another public method to call and play it.

That would be really easy on playing the one-time-only audio clips by using singleton.




A passionate gamer whose goal is to work in video game development.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Paralympian @madison.____

The Ultimate Guide to GCP’s Logging Query Language

SES is not supported in your AWS region? Here’s what you can do

Concurrency in Go — #23

Go Lean or Go Agile: A Brief Analysis

Contributing and bringing machine learning to JavaScript ecosystem with TensorFlow.js

GitHub | Learn The Linear Workflow

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
S.J. Jason Liu

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.

More from Medium

What is a Control Track in Timeline

Using Height Maps and Pixel Displacement in Unity3D

2.5D Platformer: Level Design Update

Unity : AI && NavMesh [FSM : (Finite State Machine with Enum)]