美文网首页
2021-10-22

2021-10-22

作者: lbfamous | 来源:发表于2021-10-22 10:32 被阅读0次
    //realtimeSinceStartup 的用处
    //
    
    using UnityEngine;
    using System.Collections;
    public class example : MonoBehaviour
    {
        public float updateInterval = 0.5F;
        private double lastInterval; 
        private int frames = 0;
        private float fps;
        void Start()
        {
            lastInterval = Time.realtimeSinceStartup; frames = 0;
        }
        void OnGUI()
        {
            GUILayout.Label("" + fps.ToString("f2"));
        }
        void Update()
        {
            ++frames; 
            float timeNow = Time.realtimeSinceStartup;
            if (timeNow > lastInterval + updateInterval)
            {
                fps = frames / timeNow - lastInterval; frames = 0; lastInterval = timeNow;
            }
        }
    }
    

    相关文章

      网友评论

          本文标题:2021-10-22

          本文链接:https://www.haomeiwen.com/subject/ngucaltx.html