using UnityEngine;
using System.Collections; public class CarGUI : MonoBehaviour
{
private const float FPS_UPDATE_INTERVAL = 0.5f;
private float fpsAccum = ;
private int fpsFrames = ;
private float fpsTimeLeft = FPS_UPDATE_INTERVAL;
private float fps = ; void Update()
{
fpsTimeLeft -= Time.deltaTime;
fpsAccum += Time.timeScale / Time.deltaTime;
fpsFrames++; if (fpsTimeLeft <= )
{
fps = fpsAccum / fpsFrames;
fpsTimeLeft = FPS_UPDATE_INTERVAL;
fpsAccum = ;
fpsFrames = ;
}
} void OnGUI()
{
GUILayout.BeginArea(new Rect(, , , ));
GUILayout.Label("Arrows: movement\nCtrl: flip car");
GUILayout.Label("FPS: " + fps.ToString("f1"));
GUILayout.EndArea();
}
}
05-11 19:33