32 lines
672 B
C#
32 lines
672 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class FPSDebugger : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
TextMeshProUGUI fpsText;
|
|
|
|
private int refreshRate = 10;
|
|
private int frameCounter = 0;
|
|
private float totalTime = 0;
|
|
|
|
|
|
void Update()
|
|
{
|
|
if (frameCounter == refreshRate)
|
|
{
|
|
var averageFps = 1.0 / (totalTime / refreshRate);
|
|
fpsText.text = averageFps.ToString("F1");
|
|
frameCounter = 0;
|
|
totalTime = 0;
|
|
} else
|
|
{
|
|
totalTime += Time.deltaTime;
|
|
frameCounter++;
|
|
}
|
|
}
|
|
}
|