Ejemplo n.º 1
0
        /// <summary>
        /// This method allows you to fade the sound from this Variation to a specified volume over X seconds.
        /// </summary>
        /// <param name="newVolume">The target volume to fade to.</param>
        /// <param name="fadeTime">The time it will take to fully fade to the target volume.</param>
        public void FadeToVolume(float newVolume, float fadeTime)
        {
            if (newVolume < 0f || newVolume > 1f)
            {
                Debug.LogError("Illegal volume passed to FadeToVolume: '" + newVolume +
                               "'. Legal volumes are between 0 and 1");
                return;
            }

            if (fadeTime <= MasterAudio.InnerLoopCheckInterval)
            {
                VarAudio.volume = newVolume; // time really short, just do it at once.
                if (VarAudio.volume <= 0f)
                {
                    Stop();
                }
                return;
            }

            if (!VarAudio.clip.IsClipReadyToPlay())
            {
                if (ParentGroup.LoggingEnabledForGroup)
                {
                    MasterAudio.LogWarning("Cannot Fade Variation '" + name + "' because it is still loading.");
                }
                return;
            }

            if (VariationUpdater != null)
            {
                VariationUpdater.FadeOverTimeToVolume(newVolume, fadeTime);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method allows you to fade the sound from this Variation to a specified volume over X seconds.
        /// </summary>
        /// <param name="newVolume">The target volume to fade to.</param>
        /// <param name="fadeTime">The time it will take to fully fade to the target volume.</param>
        public void FadeToVolume(float newVolume, float fadeTime)
        {
            if (newVolume < 0f || newVolume > 1f)
            {
                Debug.LogError("Illegal volume passed to FadeToVolume: '" + newVolume +
                               "'. Legal volumes are between 0 and 1");
                return;
            }

            if (fadeTime <= MasterAudio.InnerLoopCheckInterval)
            {
                VarAudio.volume = newVolume; // time really short, just do it at once.
                if (VarAudio.volume <= 0f)
                {
                    Stop();
                }
                return;
            }

            if (VariationUpdater != null)
            {
                VariationUpdater.FadeOverTimeToVolume(newVolume, fadeTime);
            }
        }