using UnityEngine;
using UnityEngine.UI;
public class FpsToShow : MonoBehaviour
{
private float fpsByDeltatime=1.5f;
private float passedTime=0.0f;
private int frameCount;
private float realFPS=0.0f;
void Update()
{
GetFPS();
}
private void GetFPS()
{
frameCount++;
passedTime += Time.deltaTime;
if (passedTime>=fpsByDeltatime)
{
realFPS = frameCount / passedTime;
this.GetComponent<Text>().text = "FPS:" + string.Format("{0:F2}",realFPS);
frameCount = 0;
passedTime = 0.0f;
}
}
}