CalculateFPS
void CalculateFPS()
{
timeleft -= Time.deltaTime;
accum += Time.timeScale / Time.deltaTime;
++frames;
// Interval ended - update GUI text and start new interval
if (timeleft <= 0.0)
{
// display two fractional digits (f2 format)
float fps = accum / frames;
string format = System.String.Format("{0:F2} FPS", fps);
fpsText = format;
timeleft = updateInterval;
accum = 0.0F;
frames = 0;
}
}