FPS:每秒运行的帧数。

using UnityEngine;

public class Fps : MonoBehaviour
{
private float m_LastTime;
private float m_UpdateInterval = 0.5f;
private float m_Frames;

void Start()
{
m_Frames = 0;
m_LastTime = Time.realtimeSinceStartup;
}

void Update()
{
m_Frames++;
float curTime = Time.realtimeSinceStartup;
// 每0.5s更新一次
if(curTime > m_LastTime + m_UpdateInterval)
{
float fps = m_Frames / (curTime - m_LastTime);
Debug.Log("The Fps: " + fps);
}
}
}