Last active
November 6, 2025 09:07
-
-
Save mstevenson/5103365 to your computer and use it in GitHub Desktop.
An accurate FPS counter for Unity. Works in builds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| public class Fps : MonoBehaviour | |
| { | |
| private float count; | |
| private IEnumerator Start() | |
| { | |
| GUI.depth = 2; | |
| while (true) | |
| { | |
| count = 1f / Time.unscaledDeltaTime; | |
| yield return new WaitForSeconds(0.1f); | |
| } | |
| } | |
| private void OnGUI() | |
| { | |
| GUI.Label(new Rect(5, 40, 100, 25), "FPS: " + Mathf.Round(count)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To get smooth FPS (Weighted average over time):