sound management in unity

gamedev unity

This tutorial uses Unity (v2022.3.6f1)

I have always thought that managing sound effects and music was tedious and difficult in unity. In this tutorial, I am going to show you my solution and how I implemented it.

My solution is based on a sound manager and scriptable objects.

Step one is to create a Sound.cs script. Now you can right click in the project window and create a new sound object.

Step two it to add a gameobject with the SoundManager script.

I have a gamemanager instance with a reference to the soundmanager so I can call Play() from every script.

The soundmanager will instaniate empty gameobjects with a AudioSource component. If you want more advanced audio features that are included in the engine, you can always edit the Sound.cs class.

Sound.cs