检测FPS工具
public class FPS : MonoBehaviour
{
public float f_UpdateInterval = 0.5F;
private float f_LastInterval;
private int i_Frames = 0;
private float f_Fps;
void Start()
{
//Application.targetFrameRate=60;
f_LastInterval = Time.realtimeSinceStartup;
i_Frames = 0;
}
void OnGUI()
{
GUI.Label(new Rect(0, 100, 200, 200), "FPS:" + f_Fps.ToString("f2"));
}
void Update()
{
++i_Frames;
if (Time.realtimeSinceStartup > f_LastInterval + f_UpdateInterval)
{
f_Fps = i_Frames / (Time.realtimeSinceStartup - f_LastInterval);
i_Frames = 0;
f_LastInterval = Time.realtimeSinceStartup;
}
}
}
标签:检测,realtimeSinceStartup,float,LastInterval,Unity,FPS,Time,Frames
From: https://www.cnblogs.com/Aaron-Han/p/12177559.html