Common(十六)—— ShowFPS显示帧数
来源:互联网 发布:python tuple 和 array 编辑:程序博客网 时间:2024/05/02 01:03
目录为:Assets/Scripts/Common/ShowFPS.cs这个脚本挂到一个GameObject上就可以了。
using UnityEngine;using System.Collections;public class ShowFPS: MonoBehaviour{ public static ShowFPS Instance { private set; get; } void OnEnable() { Instance = this; } void OnDisable() { Instance = null; } public float f_UpdateInterval = 0.5f; private float f_LastInterval; //总的渲染的帧数 private int i_Frames = 0; private float f_Fps; //用这个可以改变默认GUI风格 private GUIStyle style = new GUIStyle (); public float sSPing { get; set; } public float cSPing { get; set; } void Start() { //游戏会尽量以这个帧率运行 Application.targetFrameRate = 300; f_LastInterval = Time.realtimeSinceStartup; i_Frames = 0; //设置GUI的风格 style.fontSize = 10; style.normal.textColor = new Color (0, 255, 0, 255); } void OnGUI() { GUI.Label (new Rect (0, 0, 200, 200), "FPS:" + f_Fps.ToString ("f2"), style); GUI.Label (new Rect (0, 10, 200, 200), "sSPing:" + sSPing.ToString("f2"), style); GUI.Label (new Rect (0, 20, 200, 200), "cSPing:" + cSPing.ToString ("f2"), style); } void Update() { ++i_Frames; //f_UpdateInterval = 0.5f; //这里表示每隔0.5s计算一次帧数 if (Time.realtimeSinceStartup > f_LastInterval + f_UpdateInterval) { //间隔时间内,渲染了多少帧,算出每秒帧数 f_Fps = i_Frames / (Time.realtimeSinceStartup - f_LastInterval); i_Frames = 0; f_LastInterval = Time.realtimeSinceStartup; } }}
阅读全文
0 0
- Common(十六)—— ShowFPS显示帧数
- 摸爬滚打DirectX11_day03——如何获取每秒帧数(FPS)
- android应用程序fps meter[帧数显示]的分析 —— 浅谈root的风险 (1)
- android应用程序fps meter[帧数显示]的分析 —— 浅谈root的风险 (2)
- android应用程序fps meter[帧数显示]的分析 —— 浅谈root的风险 (3)
- android应用程序fps meter[帧数显示]的分析 —— 浅谈root的风险
- torque 显示游戏帧数
- UE4之显示游戏帧数
- (六)用JAVA编写MP3解码器——帧数据结构
- opencv播放视频实时显示帧速(FPS),即是每秒帧数
- 高通LCD之显示帧数据简析
- 【Unity】查看与显示游戏帧数FPS
- 高通LCD之显示帧数据简析
- UE4程序如何实时显示帧数
- Cocos2d—X游戏开发之 CCLabelTTF 标签详解和对齐方式设置(分数显示)(十六)
- linux常用命令—— 设备管理(十六)
- (十六)Spring框架——AOP
- angular学习(十六)——ngRoute
- Linux如何理解用数字表示文件的操作权限
- Vue生态——vue-router
- 在网页上实现大华视频监控摄像头在线
- 面试登记表样式
- codeforces 837D Round Subset (dp)
- Common(十六)—— ShowFPS显示帧数
- 2017.9.30 CF #R4 D 思考记录
- 51Nod-1403 有趣的堆栈
- Qt窗口部件
- 数据结构 P30 算法实现 链表的头插法 尾插法
- STL_stack
- vim在多个页面之间的复制粘贴
- [k8s]minikube安装配置-使用
- Win10:如何修改双网卡的优先级?