Skip to content

Instantly share code, notes, and snippets.

@birdinforest
Forked from mstevenson/Fps.cs
Last active August 26, 2016 06:09
Show Gist options
  • Save birdinforest/9e43fed776459695c02a to your computer and use it in GitHub Desktop.
Save birdinforest/9e43fed776459695c02a to your computer and use it in GitHub Desktop.
Show Fps.
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