博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Unity之显示fps功能
阅读量:4312 次
发布时间:2019-06-06

本文共 1008 字,大约阅读时间需要 3 分钟。

如下:

using UnityEngine;using System.Collections;public class ShowFpsOnGUI : MonoBehaviour{    public float fpsMeasuringDelta = 2.0f;    public int TargetFrame = 30;    private float timePassed;    private int m_FrameCount = 0;    private float m_FPS = 0.0f;    private void Start()    {        timePassed = 0.0f;        Application.targetFrameRate = TargetFrame;    }    private void Update()    {        m_FrameCount = m_FrameCount + 1;        timePassed = timePassed + Time.deltaTime;        if (timePassed > fpsMeasuringDelta)        {            m_FPS = m_FrameCount / timePassed;            timePassed = 0.0f;            m_FrameCount = 0;        }    }    private void OnGUI()    {        GUIStyle bb = new GUIStyle();        bb.normal.background = null;        bb.normal.textColor = new Color(1.0f, 0.5f, 0.0f);        bb.fontSize = 32;        //居中显示FPS        GUI.Label(new Rect(0, 0, 200, 200), "FPS: " + m_FPS, bb);    }}
View Code

转载请注明出处:

效果如下:

 

转载于:https://www.cnblogs.com/jietian331/p/8625306.html

你可能感兴趣的文章
学生信息管理系统应用ios源码iPad版
查看>>
Android中使用http协议访问网络
查看>>
ASP.NET Core 菜鸟之路:从Startup.cs说起
查看>>
vs win32 & MFC 指针默认位置
查看>>
Join 与 CountDownLatch 之间的区别
查看>>
js存cookie
查看>>
vc6下dll调试
查看>>
Ubuntu apt常用命令
查看>>
struts2 配置(部分)
查看>>
python代码迷之错误(ModuleNotFoundError: No module named 'caffe.proto')
查看>>
nodejs adm-zip 解压文件 中文文件名乱码 问题解决
查看>>
MapReduce-文本输入
查看>>
在Linux中简单实现回收子进程
查看>>
<Bootstrap> 学习笔记六. 栅格系统使用案例
查看>>
学习blus老师js(6)--js运动基础
查看>>
谈谈架构非功能性
查看>>
【timeisprecious】【JavaScript 】JavaScript RegExp 对象
查看>>
How to set colors of HTML tables
查看>>
Cannot parse POST parameters of request: '<URL>'
查看>>
Hibernate 关联映射
查看>>