Exemple #1
0
    private static IEnumerator FadeRoutine(FadeUITransition uITransition)
    {
        float currentTime = 0f;

        if (uITransition.withDisableTouch)
        {
            EventSystem.SetActive(false);
        }

        while (currentTime < 1f)
        {
            uITransition.CanvasGroup.alpha = Mathf.Lerp(uITransition.StartAlpha, uITransition.EndAlpha, uITransition.Curve.Evaluate(currentTime));
            currentTime += Time.deltaTime / uITransition.TransitionTime;
            yield return(null);
        }

        uITransition.CanvasGroup.alpha = 0f;

        if (uITransition.withDisableTouch)
        {
            EventSystem.SetActive(true);
        }

        uITransition.OnDone?.Invoke();
    }
Exemple #2
0
    public void CreateBlink(float time)
    {
        FadeUITransition fadeOut = new FadeUITransition(
            GetComponent <CanvasGroup>(),
            .5f, 0f, _inOutCurve, time / 2f);


        FadeUITransition fadeIn = new FadeUITransition(
            GetComponent <CanvasGroup>(),
            0f, .5f, _inOutCurve, time / 2f,
            () => fadeOut.Play()
            );

        fadeIn.Play();
    }
Exemple #3
0
 public static void Fade(FadeUITransition uITransition) =>
 Instance.StartCoroutine(FadeRoutine(uITransition));