Esempio n. 1
0
    IEnumerator ShowThenHideMonlogue2(string _msg)
    {
        float startAlpha = 0, endAlpha = 1;

        //隐藏之前的信息(如果有)
        while (canvasRender.GetAlpha() != startAlpha)
        {
            yield return(new WaitForEndOfFrame());

            float tempAlpha = Mathf.MoveTowards(canvasRender.GetAlpha(), startAlpha, Time.deltaTime * changeSpeed * 2f);
            YaMath.SetCanvasRenderAlphaWithChildren(this.transform, tempAlpha);
        }

        //显示现在的信息
        monologueText.text = _msg;
        while (canvasRender.GetAlpha() != endAlpha)
        {
            yield return(new WaitForEndOfFrame());

            float tempAlpha = Mathf.MoveTowards(canvasRender.GetAlpha(), endAlpha, Time.deltaTime * changeSpeed);
            YaMath.SetCanvasRenderAlphaWithChildren(this.transform, tempAlpha);
        }
        //屏幕暂留
        yield return(new WaitForSeconds(showTimeByWord * _msg.Length));

        yield return(new WaitForSeconds(addShowTime));

        //隐藏现在的信息
        while (canvasRender.GetAlpha() != startAlpha)
        {
            yield return(new WaitForEndOfFrame());

            float tempAlpha = Mathf.MoveTowards(canvasRender.GetAlpha(), startAlpha, Time.deltaTime * changeSpeed);
            YaMath.SetCanvasRenderAlphaWithChildren(this.transform, tempAlpha);
        }
    }