Googling around, a way for calculating framerate and displaying it as text ingame is using 1/Time.deltaTime. However, comparing this against unity stats FPS shows 2 different FPS. Which of it is incorrect? If 1/Time.deltaTime is incorrect, how does one go about calculating FPS?

Below is a screenshot of the FPS difference, as seen in the profiler, fps is well below 100 FPS whereas calculated FPS stays around 60.

enter image description here


1 / Time.deltaTime is the actual FPS that the whole Unity window (or the game after building and running) is running at.

The FPS that the Stats window shows is the reciprocal of only the time taken to do the frame update and render the game view, and does not include the time taken in the editor to draw the scene view, inspector and other editor-only processing.

Time.deltaTime is (as per the docs) The time in seconds it took to complete the last frame. Or rather, it can also be defined as the difference in Time.time (time since start at beginning of frame) in the last frame and the current frame.

Thus, when run in the editor, Time.deltaTime includes time taken in the editor to draw the scene view, inspector and other editor-only processing, whereas the delta time and FPS in the Stats window excludes this time.

In your case, both the calculated FPS and the Profiler window are correct, since you have VSync on for your game. Zoom into the Profiler graph and you'll see that it too shows a relatively steady 60 FPS because of VSync. To actually see the difference, open the Stats window while playing the game and compare the delta time/FPS shown there and your calculated FPS with VSync off.

Time.deltaTime minus the delta time shown in the Stats window is the time it took to process and render the Unity editor.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.