Exemple #1
0
    private IEnumerator FlashMessage(string message, int numTimes, float fadeIntime, float persistTime, float fadeOutTime)
    {
        displaying = true;
        text.StopAllCoroutines();               // stop any previous crossFadeAlpha in progress
        text.text = message;
        while (numTimes > 0)
        {
            text.canvasRenderer.SetAlpha(0);
            text.CrossFadeAlpha(1, fadeIntime, true);
            yield return(new WaitForSecondsRealtime(fadeIntime));

            text.canvasRenderer.SetAlpha(1);
            if (OnFlashMessage != null)
            {
                OnFlashMessage();
            }
            yield return(new WaitForSecondsRealtime(persistTime));

            text.CrossFadeAlpha(0, fadeOutTime, true);                  // fade out

            yield return(new WaitForSecondsRealtime(fadeOutTime + 0.1f));

            numTimes--;
        }
        displaying     = false;
        OnFlashMessage = null;
    }