1
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user