Пример #1
0
 IEnumerator FadeOut()
 {
     while (color.a > 0)
     {
         // StartValue / duration * deltaTime
         color.a -= 1f / timeToFade * Time.deltaTime;
         material.SetFloat("_FadeAmount", color.a);
         yield return(null);
     }
     callBack?.Invoke();
 }
    private IEnumerator FadeCoroutine(float timeToTake, float startA, float endA, bool destroyOnComplete)
    {
        imageBlack.gameObject.SetActive(true);
        imageBlack.enabled = true;

        Color baseColor = imageBlack.color;

        float startTime = Time.time;

        while (true)
        {
            float t = (Time.time - startTime) / timeToTake;

            if (t >= 1)
            {
                break;
            }
            else
            {
                imageBlack.color = LerpA(baseColor, startA, endA, t);
            }

            yield return(new WaitForFixedUpdate());
        }

        imageBlack.color = LerpA(baseColor, startA, endA, 1);

        FadeCompleted?.Invoke();
        if (destroyOnComplete)
        {
            Destroy(gameObject);
        }
    }
Пример #3
0
        private void Update()
        {
            if (!m_enabled)
            {
                return;
            }

            m_alpha += m_fadeSpeed * (Time.deltaTime > 0 ? Time.deltaTime : Time.unscaledDeltaTime) * m_sign;

            if (FadeUpdate != null)
            {
                FadeUpdate.Invoke(m_sign, m_alpha);
            }

            if ((m_sign == 1 && m_alpha >= 1) || (m_sign == -1 && m_alpha <= 0))
            {
                m_alpha = m_sign == 1 ? 1 : 0;

                if (m_alpha <= 0)
                {
                    m_enabled = false;
                }

                if (FadeCompleted != null)
                {
                    FadeCompleted.Invoke();
                }
            }
        }
Пример #4
0
 private async void Fade_Completed(object sender, AnimationSetCompletedEventArgs e)
 {
     if (sender is AnimationSet animSet)
     {
         FadeCompleted?.Invoke(sender, e);
         animSet.Completed -= FadeCompleted;
         _animations.Remove(animSet);
         await ShowControlAsync();
     }
 }
Пример #5
0
        /// <summary>
        /// Begin fading the form.
        /// </summary>
        private DialogResult beginFade()
        {
            while (updateOpacity())
            {
                Application.DoEvents();
                Thread.Sleep(10);
            }

            fadeFinished?.Invoke();

            return(dialogResult);
        }
Пример #6
0
        /// <summary>
        /// Fade the form out at the defined speed.
        /// </summary>
        private void fadeOut(float fadeSpeed, FadeCompleted finished)
        {
            if (form.Opacity < 0.1)
            {
                finished?.Invoke();
                return;
            }

            fadeFinished   = finished;
            form.Opacity   = 100;
            this.fadeSpeed = fadeSpeed;
            fadeDirection  = FadeDirection.Out;

            beginFade();
        }
Пример #7
0
 protected virtual void OnFadeCompleted(FadeEventArgs e)
 {
     FadeCompleted?.Invoke(this, e);
 }