37 lines
574 B
C#
37 lines
574 B
C#
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class FPSInfo : MonoBehaviour
|
|
{
|
|
private float fps;
|
|
|
|
[SerializeField]
|
|
private float updateFrequency = 0.2f;
|
|
|
|
private float updateTimer;
|
|
|
|
[SerializeField]
|
|
private TextMeshProUGUI fpsTitle;
|
|
|
|
private void UptadeFPSDisplay()
|
|
{
|
|
updateTimer -= Time.deltaTime;
|
|
if (updateTimer <= 0f)
|
|
{
|
|
fps = 1f / Time.unscaledDeltaTime;
|
|
fpsTitle.text = "FPS: " + Mathf.Round(fps);
|
|
updateTimer = updateFrequency;
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
UptadeFPSDisplay();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
updateTimer = updateFrequency;
|
|
}
|
|
}
|