Show Editor window true framerate in the fps counter widget

This commit is contained in:
2023-10-01 18:27:02 +03:00
parent 7ed59a4426
commit 0fb0492738

View File

@@ -1241,6 +1241,10 @@ namespace FlaxEditor.Viewport
private class FpsCounter : Control
{
private int fps;
private int accumFrames;
private float lastUpdate;
public FpsCounter(float x, float y)
: base(x, y, 64, 32)
{
@@ -1250,7 +1254,15 @@ namespace FlaxEditor.Viewport
{
base.Draw();
int fps = Engine.FramesPerSecond;
accumFrames++;
float timeNow = Time.TimeSinceStartup;
if (timeNow - lastUpdate >= 1.0f)
{
fps = accumFrames;
lastUpdate = timeNow;
accumFrames = 0;
}
Color color = Color.Green;
if (fps < 13)
color = Color.Red;