The Basics Of Audio In Unity

As with almost everything in Unity, audio is implemented by means of a component. While there are several audio components available for advanced features, the basic implementation of audio starts with an audio source component. This component specifies a single AudioClip, which can be defined both through scripting and directly through drag and drop in the inspector.

There is a lot you can do with just an Audio Source component

Without even any scripting you can enable both Loop and Play On Awake, if all you need is to have a sound play immediately when an object is spawned, or indefinitely while it exists in the scene. For more precise control of audio as usual we turn to scripting, where a few simple lines of code let us play sound effects from a game object.

This is most often all you need

There are a few special play modes such as PlayOneShot and PlayDelayed to cover all the ways that you might need to play a sound, but for the most part Play is all you need to get a sound playing.

So Many Choices

Many more audio components exist, covering many advanced features helpful in highly complex games. This means Unity is probably all you need for your sound implementation, even though third party sound engines like Wwise are supported through the use of plugins.

Game developer with over 12 years of experience, mainly focused on MMOs.