This commit is contained in:
2026-07-11 19:05:27 +08:00
parent 44057b5a14
commit 24815d044c
10 changed files with 521 additions and 36 deletions
@@ -315,6 +315,32 @@ public class GameManager : MonoSingleton<GameManager>
}
#endif
// FPS 统计
fpsFrameCount++;
fpsTimer += Time.unscaledDeltaTime;
if (fpsTimer >= 0.5f)
{
fps = Mathf.RoundToInt(fpsFrameCount / fpsTimer);
fpsFrameCount = 0;
fpsTimer = 0f;
}
}
// ===== FPS 显示 =====
private int fpsFrameCount;
private float fpsTimer;
private int fps;
void OnGUI()
{
// 左上角显示帧数
GUIStyle style = new GUIStyle(GUI.skin.label)
{
fontSize = 28,
fontStyle = FontStyle.Bold
};
style.normal.textColor = fps >= 50 ? Color.green : (fps >= 30 ? Color.yellow : Color.red);
GUI.Label(new Rect(10, 10, 200, 40), "FPS: " + fps, style);
}
public void Logout(Action onDone = null)