From the course: Cert Prep: Unity Certified Associate Game Developer Audio and Effects

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Create a volume fade-in

Create a volume fade-in - Unity Tutorial

From the course: Cert Prep: Unity Certified Associate Game Developer Audio and Effects

Start my 1-month free trial

Create a volume fade-in

- [Instructor] In this movie, we're going to continue with our VolumeFader. We've created a script here that uses the Audio namespace and we're referencing our AudioMixer asset that is in our project, and we're going to be using this script to fade in the audio over time. The first thing that I'll need to do to create that is to create an initial variable specifying the fade in time. So in this case, that's going to be public float, and then FadeTime. I'll specify the initial time of 15 seconds. And because this is a public variable, it's easy for me to just change the value directly inside the Inspector. The next thing that I want to do is to create a completely separate function that is going to convert between a linear and a decibel scale. In Unity, we need to specify the volume in decibels, but that is not always intuitive to think about volume in that way. Often, we'll want to think about volume in terms of…

Contents