Unity3D 计算FPS
2016-10-13 20:22
141 查看
using UnityEngine; using System.Collections; public class FPS : MonoBehaviour { private const string DISPLAY_TEXT_FORMAT = "{0} msf\n({1} FPS)"; private const string MSF_FORMAT = "#.#"; private const float MS_PER_SEC = 1000f; private string textField; private float fps = 60; void Awake() { } void Start() { } void LateUpdate() { float interp = Time.deltaTime / (0.5f + Time.deltaTime); float currentFPS = 1.0f / Time.deltaTime; fps = Mathf.Lerp(fps, currentFPS, interp); float msf = MS_PER_SEC / fps; textField = string.Format(DISPLAY_TEXT_FORMAT, msf.ToString(MSF_FORMAT), Mathf.RoundToInt(fps)); } GUIStyle style = new GUIStyle(); void OnGUI() { style.fontSize = 30; style.normal.textColor = Color.white; GUI.Label(new Rect(0, 0, 200, 100), textField, style); } }
相关文章推荐
- Unity3D之FPS计算
- Unity3d 2017.3 计算分数
- [Unity3D]查看与设置游戏帧数FPS
- Unity3D中如何计算场景中的三角面和顶点数
- Unity3D FPS
- Unity3D 大型游戏 最后一站 源码 部分重点 显示FPS
- unity3d 中使用Profiler看到的一项"WaitForTargetFPS"费资源过高的原因
- as3.0 fps计算 顺便 显示内存占用
- 帧率(FPS)计算的六种方法总结
- unity3d计算两物体之间的夹角
- Unity3D研究院之主角面朝方向一定区域内对象角度计算
- Unity3D研究院之主角面朝方向一定区域内对象角度计算
- 【Unity3D】计算二维向量夹角(-180到180)
- h323协议 计算FPS 帧率
- unity3d easytouch计算摇杆旋转角度以及摇杆八方向控制角色
- Unity3D开发之计算向量角度的方式
- Unity3D——主角面朝方向一定区域内对象角度计算
- [Unity3D]查看与设置游戏帧数FPS
- Unity3D研究院之主角面朝方向一定区域内对象角度计算(四十五)
- JAVA游戏开发计算显示FPS