示例#1
0
        private IEnumerator RunFadeVolume(VolumeFadeParameters parameters)
        {
            float t;

            t = 0;

            float frameRate;

            frameRate = (Application.targetFrameRate > 0) ? Application.targetFrameRate : 60;

            float step;

            step = 1 / (frameRate * parameters.Duration);

            this.Volume = parameters.From;

            while (t < 1)
            {
                yield return(null);

                t           = Mathf.Clamp(t + step, 0, 1);
                this.Volume = Quadratic.EaseInOut(parameters.From, parameters.To, t);
            }

            if (parameters.Completion != null)
            {
                parameters.Completion(this);
            }
        }
示例#2
0
        public void FadeVolume(float from, float to, float duration, AudioPlayer.Delegate completionDelegate)
        {
            string coroutine;

            coroutine = "RunFadeVolume";

            VolumeFadeParameters parameters;

            parameters = new VolumeFadeParameters()
            {
                Completion = completionDelegate,
                Duration   = duration,
                From       = (from >= 0) ? from : this.Volume,
                To         = to
            };

            StopCoroutine(coroutine);
            StartCoroutine(coroutine, parameters);
        }
示例#3
0
        public void FadeVolume(float from, float to, float duration, Delegate completionDelegate)
        {
            if (!this.gameObject.activeInHierarchy)
            {
                return;
            }

            VolumeFadeParameters parameters;

            parameters = new VolumeFadeParameters()
            {
                Completion = completionDelegate,
                Duration   = duration,
                From       = (from >= 0) ? from : this.Volume,
                To         = to
            };

            StopCoroutine(FADE_VOLUME_COROUTINE);
            StartCoroutine(FADE_VOLUME_COROUTINE, parameters);
        }