private IEnumerator _SetVolume(Sound sound, float from, float to, float time)
    {
        float typeVolume = GetVolumeDial(sound.Type);
        float start      = MasterVolume * typeVolume * sound.MaxVolume * from;
        float end        = MasterVolume * typeVolume * sound.MaxVolume * to;

        float progress = 0;

        while (progress <= 1)
        {
            //continuously update the end value in case the user changes any volume settings while the volume is changing
            end = MasterVolume * typeVolume * sound.MaxVolume * to;

            sound.Volume = Mathf.Lerp(start, end, progress);
            sound.ApplyValues();

            progress += Time.deltaTime / time;
            yield return(null);
        }

        if (end == 0)
        {
            sound.Source.Stop();
            sound.SetVolume(MasterVolume * typeVolume * sound.MaxVolume * 1);
        }
        else
        {
            sound.Volume = end;
        }

        sound.ApplyValues();
    }
    /// <summary>
    /// Sets the volume of the sound effect with the given name to a value between 0 and 1.
    /// Calculates the new volume level based on MaxVolume (which is the level the sound is set at on start), TypeVolume (which is the volume of the sound category), and MasterVolume (which is the main volume)
    /// </summary>
    public void SetVolume(string name, float to)
    {
        Sound sound      = GetSound(name);
        float typeVolume = GetVolumeDial(sound.Type);

        to = Mathf.Clamp(to, 0, 1);

        sound.Volume = MasterVolume * typeVolume * sound.MaxVolume * to;
        sound.ApplyValues();
    }
    /// <summary>
    /// Initializes a Sound by creating an AudioSource, setting the proper clip, and leveling the volume
    /// </summary>
    private void InitializeSound(GameObject container, Sound sound, SoundType type, float typeVolume)
    {
        Dictionary.Add(sound.Name, sound);

        sound.Type        = type;
        sound.Source      = container.AddComponent <AudioSource>();
        sound.Source.clip = sound.Clips[0];

        sound.MaxVolume = sound.Volume;
        sound.Volume    = MasterVolume * typeVolume * sound.Volume;

        sound.ApplyValues();
        if (sound.PlayOnAwake)
        {
            sound.Source.Play();
        }
    }