-
-
Save hoverbird/babeb35b06bbf00aa6c8584691e58df7 to your computer and use it in GitHub Desktop.
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 { | |
string label = ""; | |
float count; | |
IEnumerator Start () | |
{ | |
GUI.depth = 2; | |
while (true) { | |
if (Time.timeScale == 1) { | |
yield return new WaitForSeconds (0.1f); | |
count = (1 / Time.deltaTime); | |
label = "FPS :" + (Mathf.Round (count)); | |
} else { | |
label = "Pause"; | |
} | |
yield return new WaitForSeconds (0.5f); | |
} | |
} | |
void OnGUI () | |
{ | |
GUI.Label (new Rect (5, 40, 100, 25), label); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment