如何在Unity中显示FPS

using UnityEngine;
using System.Collections; public class example : MonoBehaviour
{
public float updateInterval = 0.5F;
private double lastInterval;
private int frames = ;
private float fps;
void Start()
{
lastInterval = Time.realtimeSinceStartup;
frames = ;
}
void OnGUI()
{
GUILayout.Label(" " + fps.ToString("f2"));
}
void Update()
{
++frames;
float timeNow = Time.realtimeSinceStartup;
if (timeNow > lastInterval + updateInterval)
{
fps = (float)(frames / (timeNow - lastInterval));
frames = ;
lastInterval = timeNow;
}
}
}
上一篇:ArcGIS API for JavaScript 4.2学习笔记[18] 搜索小部件


下一篇:如何在Unity中画抛物线