FPS的Log代码
2016-02-11 22:08
351 查看
FPS是图像领域中的定义,是指画面每秒传输帧数,通俗来讲就是指动画或视频的画面数。FPS是测量用于保存、显示动态视频的信息数量。每秒钟帧数愈多,所显示的动作就会愈流畅。通常,要避免动作不流畅的最低是30。某些计算机视频格式,每秒只能提供15帧。
FPS”也可以理解为我们常说的“刷新率(单位为Hz)”,例如我们常在CS游戏里说的“FPS值”。我们在装机选购显卡和显示器的时候,都会注意到“刷新率”。一般我们设置缺省刷新率都在75Hz(即75帧/秒)以上。例如:75Hz的刷新率刷也就是指屏幕一秒内只扫描75次,即75帧/秒。而当刷新率太低时我们肉眼都能感觉到屏幕的闪烁,不连贯,对图像显示效果和视觉感观产生不好的影响。
FPS.cs
ShowFPS.cs
每秒刷新60帧,手机帧频可以到理想状态。
FPS”也可以理解为我们常说的“刷新率(单位为Hz)”,例如我们常在CS游戏里说的“FPS值”。我们在装机选购显卡和显示器的时候,都会注意到“刷新率”。一般我们设置缺省刷新率都在75Hz(即75帧/秒)以上。例如:75Hz的刷新率刷也就是指屏幕一秒内只扫描75次,即75帧/秒。而当刷新率太低时我们肉眼都能感觉到屏幕的闪烁,不连贯,对图像显示效果和视觉感观产生不好的影响。
FPS.cs
using UnityEngine; using System.Collections; public class FPS : MonoBehaviour { public float f_updatInterval = 0.3f; private float f_LastInterval; private int i_Frames =0; private float f_Fps; void Start () { f_LastInterval = Time.realtimeSinceStartup; i_Frames = 0; } // Update is called once per frame void Update () { ++i_Frames; if (Time.realtimeSinceStartup > f_LastInterval + f_updatInterval) { f_Fps = i_Frames / (Time.realtimeSinceStartup - f_LastInterval); i_Frames = 0; f_LastInterval = Time.realtimeSinceStartup; } } void OnGUI() { GUI.Label (new Rect(0,100,200,200),"FPS"+ f_Fps.ToString("f2")); } }
ShowFPS.cs
using UnityEngine; using System.Collections; public class ShowFPS : MonoBehaviour { float deltaTime = 0.0f; void Update() { deltaTime += (Time.deltaTime - deltaTime) * 0.1f; } void OnGUI() { int w = Screen.width; int h = Screen.height; GUIStyle style = new GUIStyle (); Rect rect = new Rect (0, 0, 100, 50); style.alignment = TextAnchor.UpperLeft; style.normal.textColor = new Color (0.0f, 0.0f, 0.5f,1.0f); float msec = deltaTime * 1000.0f; float fps = 1.0f / deltaTime; string text = string.Format ("{0:0.0}ms({1:0})fps",msec,fps); GUI.Label (rect,text,style); } }
每秒刷新60帧,手机帧频可以到理想状态。
相关文章推荐
- Arcgis server java develop begining
- Gradle教程Part2:java工程
- 链表ADT C语言实现
- neuq oj 1017平面切割(特别版)C++
- Python图像处理库PIL的基本模块介绍
- 第十一章编程练习(7)
- 017 QtCreator生成美观的可执行文件
- Java开发环境搭建
- ASCII编码
- vb学习之十三
- 风雨20年:我所积累的20条编程经验
- vb学习之十二
- vb学习之十一
- vb学习之十
- java基础总结 --- enum枚举实现多路分发 石头、剪刀、布游戏示例
- The Java™ Tutorials — Concurrency :Memory Consistency Errors 内存一致性错误
- Spark学习笔记7-在eclipse里用scala编写spark程序(单机和集群运行)
- vb学习之六
- vb学习之五
- vb学习之四