示例#1
0
    private IEnumerator TextFadeIn(float fadeTime, float fadeMagnitude)
    {
        if (UITexts.Count > 0)
        {
            float oppacity = 0;
            foreach (TextMeshProUGUI text in UITexts)
            {
                text.color = new Color(text.color.r, text.color.g, text.color.b, oppacity);
            }


            while (oppacity < 1f)
            {
                oppacity += fadeMagnitude;

                foreach (TextMeshProUGUI text in UITexts)
                {
                    if (oppacity >= 0.95)
                    {
                        oppacity = 1f;
                    }
                    text.color = new Color(text.color.r, text.color.g, text.color.b, oppacity);
                }

                yield return(new WaitForSeconds(fadeTime));
            }
        }

        OnTextFadeEnd?.Invoke();
    }
示例#2
0
    private IEnumerator TextFadeOut(float fadeTime, float fadeMagnitude)
    {
        if (UITexts.Count > 0)
        {
            float oppacity = 1f;
            foreach (TextMeshProUGUI text in UITexts)
            {
                if (text.isActiveAndEnabled)
                {
                    text.color = new Color(text.color.r, text.color.g, text.color.b, oppacity);
                }
            }


            while (oppacity > 0f)
            {
                oppacity -= fadeMagnitude;

                foreach (TextMeshProUGUI text in UITexts)
                {
                    if (text.isActiveAndEnabled)
                    {
                        if (oppacity <= 0.05)
                        {
                            oppacity = 0f;
                        }
                        text.color = new Color(text.color.r, text.color.g, text.color.b, oppacity);
                    }
                }

                yield return(new WaitForSeconds(fadeTime));
            }
        }

        OnTextFadeEnd?.Invoke();
    }