Ejemplo n.º 1
0
        /// <summary>
        /// Plays the fade effect.
        /// </summary>
        public override IEnumerator Play()
        {
            control = GetComponent<GUIVisibleControl>();
            if (control == null) yield break;

            // Fade in:
            float startTime = DialogueTime.time;
            float endTime = startTime + fadeInDuration;
            while (DialogueTime.time < endTime) {
                float elapsed = DialogueTime.time - startTime;
                control.Alpha = elapsed / fadeInDuration;
                yield return null;
            }
            control.Alpha = 1;

            // If no fade out, exit:
            if (Tools.ApproximatelyZero(fadeOutDuration)) yield break;

            // Visible duration:
            yield return new WaitForSeconds(duration);

            // Fade out:
            startTime = DialogueTime.time;
            endTime = startTime + fadeOutDuration;
            while (DialogueTime.time < endTime) {
                float elapsed = DialogueTime.time - startTime;
                control.Alpha = 1 - (elapsed / fadeOutDuration);
                yield return null;
            }
            control.Alpha = 0;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Plays the fade effect.
        /// </summary>
        public override IEnumerator Play()
        {
            control = GetComponent <GUIVisibleControl>();
            if (control == null)
            {
                yield break;
            }

            // Fade in:
            float startTime = DialogueTime.time;
            float endTime   = startTime + fadeInDuration;

            while (DialogueTime.time < endTime)
            {
                float elapsed = DialogueTime.time - startTime;
                control.Alpha = elapsed / fadeInDuration;
                yield return(null);
            }
            control.Alpha = 1;

            // If no fade out, exit:
            if (Tools.ApproximatelyZero(fadeOutDuration))
            {
                yield break;
            }

            // Visible duration:
            yield return(StartCoroutine(DialogueTime.WaitForSeconds(duration))); // new WaitForSeconds(duration);

            // Fade out:
            startTime = DialogueTime.time;
            endTime   = startTime + fadeOutDuration;
            while (DialogueTime.time < endTime)
            {
                float elapsed = DialogueTime.time - startTime;
                control.Alpha = 1 - (elapsed / fadeOutDuration);
                yield return(null);
            }
            control.Alpha = 0;
        }