小编Gen*_*rus的帖子

我的 FPS 计数器不准确,为什么?

当我开始我的游戏时,它保持在 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 = …
Run Code Online (Sandbox Code Playgroud)

c# frame-rate performancecounter frame unity-game-engine

1
推荐指数
1
解决办法
5654
查看次数