Aside from downloading content from the Asset Store, there are a number of ways of introducing content into a Unity project. Most often, the simplest way of adding content to your project is placing the appropriate files into the relevant project folders. Unity is then smart enough to inspect the new files, provided the file type is supported by Unity, and determine the asset type to automatically import the content. Since there are a number of audio file types out there, let's take a look at the audio file format Unity currently supports in the following list:
- .wav / .aif: Both of these formats are uncompressed, lossless formats, which means they are exact copies of the original audio. The .aif originated on the Mac, while .wav came from the PC. Now both formats are supported by either operating system.
- .mp3: This is the most common compressed or lossy format for audio. This format became very popular for transferring/downloading music.
- .ogg: This, also known as Ogg Vorbis, was developed as a patent free alternative to mp3. The standard format is lossy but it can support lossless as well.
Now that you have a better understanding of the supported audio files types, let's import a couple of files into our project in the following exercise here:
- Before importing any content, we will create a new set of folders in the project. This will help us organize and find this content later. As you can see, by just taking a quick look through the Project window, a game project may contain numerous assets in multiple areas.
- Right-click (control + Click on Mac) on the root Assets folder in the Project window. Then, select Create | Folder from the context menu.
- A new folder will be created under the Assets folder with the cursor prompting for input. Name the new folder Audio.
- Right-click (control + Click on Mac) on the new Audio folder and select Create | Folder from the context menu. Name the folder Ambient and your Project window now look like the following screenshot:
- Right-click [control + Click on Mac] on the Ambient folder and select Show in Explorer from the context menu. This will open a file explorer on your desktop. Double-click on on the Ambient folder to open it; the folder should be empty.
- Go to your desktop and open the books downloaded source code Chapter_1_Audio folder in another file explorer window. Drag the folders so that they are adjacent to each other and both visible. A sample screenshot is shown here:
- Drag and drop all the files from the Chapter_1_Audio folder into the Ambient folder. Then, switch back to the Unity editor. After a couple seconds, you should see the Ambient folder in the Project window update with the imported audio files, as shown here:
- Select the lake-shore-waves2.wav audio clip in the folder and then divert your attention to the Inspector window. You should see something similar to what is shown here:
- Click on the asset play button, as shown in the preceding screenshot, and enjoy the soothing sounds of waves hitting the lake shore. We will get into more details about what those other properties are in the next section.