通过实例观察WaitForEndOfFrame()作用

 private IEnumerator EndOfGame(string winner, int score)
    {
        float timer = 5.0f;

        while (timer > 0.0f)
        {
            InfoText.text = string.Format("Player {0} won with {1} points.\n\n\nReturning to login screen in {2} seconds.", winner, score, timer.ToString("n2"));

            yield return new WaitForEndOfFrame();

            timer -= Time.deltaTime;
        }

        PhotonNetwork.LeaveRoom();
    }

yield return new WaitForEndOfFrame();执行顺序可以说是等当前帧执行完之后紧接执行后面程序,在本例中就是计时器计时。Lateupdate()之后执行。

发布了49 篇原创文章 · 获赞 8 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_23158477/article/details/90338966
今日推荐