An accurate FPS counter for Unity. Works in builds.
This file contains 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)); | |
} | |
} |
good
good
good
Use Time.unscaledDeltaTime
instead, so that you can continue to calculate an accurate FPS while the Time.timeScale
is not 1.
Replaced with Time.unscaledDeltaTime
, thanks
Thank you! Simple and works!
Thanks!!!!!
Works great! If you're looking for a little bit more detail, replace OnGUI
with this:
private void OnGUI()
{
Rect location = new Rect(5, 5, 85, 25);
string text = $"FPS: {Mathf.Round(count)}";
Texture black = Texture2D.linearGrayTexture;
GUI.DrawTexture(location, black, ScaleMode.StretchToFill);
GUI.color = Color.black;
GUI.skin.label.fontSize = 18;
GUI.Label(location, text);
}
thanks mate
good, thanks!
nice
nice
Thanks bruv
good
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good