25 lines
539 B
C#
25 lines
539 B
C#
|
|
using TMPro;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class FPSCounter : MonoBehaviour
|
||
|
|
{
|
||
|
|
public TMP_Text FramerateText;
|
||
|
|
|
||
|
|
[SerializeField] private float RFRate = 1f;
|
||
|
|
|
||
|
|
private float Timer;
|
||
|
|
|
||
|
|
private void Update()
|
||
|
|
{
|
||
|
|
if (FramerateText.gameObject.activeInHierarchy)
|
||
|
|
{
|
||
|
|
if (Time.unscaledTime > Timer)
|
||
|
|
{
|
||
|
|
int fps = (int)(1f / Time.unscaledDeltaTime);
|
||
|
|
FramerateText.text = "FPS: " + fps;
|
||
|
|
Timer = Time.unscaledTime + RFRate;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|