Audio
Learn how to implement audio in Unity to create immersive sound effects and music to enrich the AR experience.1
Introduction to audio in Unity
Audio is an essential component of any game or interactive experience. Unity offers robust tools for working with audio, including built-in support for 3D sound, sound effects, music, and more. In this lesson, we'll explore the basics of working with audio in Unity, including how to import and manage audio assets and create and manipulate audio sources. We'll also use Unity’s built-in audio effects to enhance the game’s audio.
Importing audio assets
Before using audio in Unity, we must import our audio assets into our project. Unity supports various audio file formats, including WAV, MP3, and OGG. To import audio assets into our project, drag and drop the files into the Unity project window or use the “Import New Asset” option from the “Assets” menu.
An example of drag and drop is presented in the illustration above.
Creating audio source
An audio source is a GameObject component that plays audio. Once we have imported our audio assets, we can create audio sources to play them back in our scene. Add an AudioSource
component to a GameObject in the scene to create an audio source.
Given below are the steps to create an audio source:
Right-click the GameObject in the “Hierarchy” window to which we want to attach the audio source.
From ...