예제 #1
0
    /// <summary>
    /// Fades the volume using animation curve.
    /// If the sound is not playing, you must call audioSource.Play() first.
    /// </summary>
    /// <param name="audioSource">Audio source.</param>
    /// <param name="toVolume">To volume.</param>
    /// <param name="time">Time.</param>
    public static void FadeVolume(AudioSource audioSource, float time, AnimationCurve interpolation)
    {
        MSAudioVolume mSAudioVolume = audioSource.GetComponent <MSAudioVolume>();

        if (mSAudioVolume == null)
        {
            mSAudioVolume = audioSource.gameObject.AddComponent <MSAudioVolume>();
        }
        mSAudioVolume.Fade(interpolation, time);
    }
예제 #2
0
    /// <summary>
    /// Fades the volume linearly to a target Volume.
    /// If the sound is not playing, you must call audioSource.Play() first.
    /// </summary>
    /// <param name="audioSource">Audio source.</param>
    /// <param name="toVolume">To volume.</param>
    /// <param name="time">Time.</param>
    public static void FadeVolume(AudioSource audioSource, float time, float targetVolume)
    {
        MSAudioVolume mSAudioVolume = audioSource.GetComponent <MSAudioVolume>();

        if (mSAudioVolume == null)
        {
            mSAudioVolume = audioSource.gameObject.AddComponent <MSAudioVolume>();
        }
        mSAudioVolume.Fade(targetVolume, time);
    }