【发布时间】:2015-10-28 17:23:28
【问题描述】:
当我开始我的游戏时,它保持在 95-101 左右的快速变化,介于所有这些数字之间。但是当我打开统计栏时,我得到了 200 和 300 的上限
所以想知道为什么这对 c# 来说仍然是新的,所以对我来说轻松点,哈哈。这是代码 一如既往地提前感谢^_^。
float deltaTime = 0.0f;
void Update()
{
deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
}
void OnGUI()
{
int w = Screen.width, h = Screen.height;
GUIStyle style = new GUIStyle ();
Rect rect = new Rect (0, 0, w, h * 2 / 100);
style.alignment = TextAnchor.UpperRight;
style.fontSize = h * 2 / 100;
style.normal.textColor = new Color (255.0f, 255.0f, 255.0f, 1.0f);
float msec = deltaTime * 1000.0f;
float fps = 1f / deltaTime;
string text = string.Format ("({1:0.} fps)", msec, fps);
GUI.Label (rect, text, style);
}
}
【问题讨论】:
标签: c# unity3d frame performancecounter frame-rate