void Update () {
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);
label.text = format;
if(fps < 10)
label.color = Color.red;
else if(fps < 30)
label.color = Color.yellow;
else
label.color = Color.green;
timeleft = updateInterval;
accum = 0.0F;
frames = 0;
}
}
}