zoukankan      html  css  js  c++  java
  • FPS interv

    using UnityEngine;
    using System.Collections;
    
    public class showFPSManager : MonoBehaviour 
    {    
        private float FPS_updateInterval = 0.5F;
        private double FPS_lastInterval;
        private int FPS_frames = 0;
        private float FPS_fps;
        private string frameText;
        // Use this for initialization
        void Start () 
        {
            FPS_lastInterval = Time.realtimeSinceStartup;
            FPS_frames = 0;    
        }
        
        // Update is called once per frame
        void Update () 
        {
            frameText= "FPS: " + CalFPS().ToString("f2");
        }
        
        public float CalFPS()
        {
             ++FPS_frames;
            float timeNow = Time.realtimeSinceStartup;
            if (timeNow > FPS_lastInterval + FPS_updateInterval) {
                FPS_fps = (float)(FPS_frames / (timeNow - FPS_lastInterval));
                FPS_frames = 0;
                FPS_lastInterval = timeNow;
            }
            
            return FPS_fps;
        }
        
        void OnGUI()
        {
            GUI.Label(new Rect(10,10,80,20),frameText);
        }
    }

     该脚本直接挂在uiroot里面的camera

  • 相关阅读:
    New-SAN-FENG-YUN-三
    San丰-Cloud
    SpringBoot+MySQL+MyBatis+Shiro+AdminLTE
    SanFeng-Clound
    SanFengClound
    传奇音乐设置
    热血传奇GOM引擎问题集锦
    app测试
    接口测试
    题目
  • 原文地址:https://www.cnblogs.com/xiao-wei-wei/p/3394309.html
Copyright © 2011-2022 走看看