Adding background music with Global 2D audio sources
We can apply background music to our scene using a 2D audio source, similar to how we were able to apply global post-processing effects with a global volume. 2D audio sources play sound that appears to come from a fixed position in the game world, similar to the directional light but without any sense of direction or distance. They are typically used for background music, voice-overs, or sound effects that are not spatially relevant.
A key component of the Unity audio system is the Audio Source
component. It allows developers to play audio in a Unity scene both globally and locally. It can be attached to any GO in the scene, such as a character or an object, and can be used to play sound effects, music, and other audio files.
The Audio Source
component has several key features:
- Audio clip: This is the audio file that will be played by the
Audio Source
component. Developers can choose from a range of audio file formats...