예제 #1
0
        /// <summary>
        /// Fades the associated CanvasGroup with the defined method
        /// </summary>
        /// <param name="method">The FadeMethod to commence</param>
        public IEnumerator Fade(FadeMethod method)
        {
            float t      = 0;
            float oldVal = AssociatedGroup.alpha;

            if (method == FadeMethod.FadeIn)
            {
                while (t <= FadeInLength)
                {
                    AssociatedGroup.alpha = Mathf.Lerp(oldVal, 1, FadeCurve.Evaluate(t / FadeInLength));
                    t += Time.deltaTime;
                    yield return(null);
                }
            }

            else
            {
                while (t <= FadeOutLength)
                {
                    AssociatedGroup.alpha = Mathf.Lerp(oldVal, 0, FadeCurve.Evaluate(t / FadeOutLength));
                    t += Time.deltaTime;
                    yield return(null);
                }
            }
        }
예제 #2
0
 private static void FadeVolume(double targetVolume, double fadeDuration, FadeCurve curve)
 {
     Console.WriteLine((targetVolume > 0.0 ? "Fade away" : "Not fade away") + $" for {fadeDuration}, using {curve}");
 }