Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Sounds in Unity | Unity UI and Sounds
Unity for Beginners
course content

Course Content

Unity for Beginners

Unity for Beginners

1. Unity Introduction
2. Write your First Script
3. Unity Physics
4. Unity UI and Sounds
5. Polishing and Export your Game

book
Sounds in Unity

Importing Audio Assets

To get started with sounds in Unity, you'll need some audio assets. These are sound files that you can either create yourself or download for free from the internet. Once you have your audio files ready, importing them into Unity is simple: just drag and drop them into the "Assets" folder in the Unity Editor. This will make them available for use in your project.

Adding an AudioSource Component

In Unity, the AudioSource component is what you use to play sound clips. Here's a simple way to add it to a GameObject:

  1. Select the GameObject: Choose the object you want to add sound to. This could be an empty GameObject or any object that you want to emit sound;

  2. Open the Inspector: With your GameObject selected, look at the Inspector window;

  3. Add the Component: Click on the "Add Component" button;

  4. Search and Select: Type "Audio Source" in the search bar and select "Audio Source" from the dropdown menu.

This will attach the AudioSource component to your GameObject, allowing it to play sounds.

Setting up the AudioSource

Once you've added the AudioSource component to your GameObject, you can configure it in the Inspector window:

  • Audio Clip: Assign the audio clip you want to play to the "Audio Clip" field. This is the actual sound file you imported in Step 1;

  • Volume: Adjust the volume of the audio clip using the "Volume" slider. This controls how loud the sound will be when played;

  • Loop: Check the "Loop" checkbox if you want the audio clip to repeat continuously;

  • Spatial Blend: Adjusts how much the audio is affected by 3D spatialization. A value of 0 means the audio is 2D (non-spatial), while a value of 1 means the audio is fully 3D spatialized;

  • Play On Awake: Check this checkbox if you want the audio clip to start playing automatically when the GameObject is activated.

These settings allow you to control how and when your audio plays, making your Unity project more interactive and immersive.

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 4. Chapter 4
We're sorry to hear that something went wrong. What happened?
some-alt