r2mods/ilspy_dump/ror2_csproj/RoR2.UI/FPS.cs

30 lines
542 B
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using TMPro;
using UnityEngine;
namespace RoR2.UI;
public class FPS : MonoBehaviour
{
public TextMeshProUGUI targetText;
private float deltaTime;
private float stopwatch;
private const float updateTime = 1f;
private void Update()
{
stopwatch += Time.unscaledDeltaTime;
deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
if (stopwatch >= 1f)
{
stopwatch -= 1f;
float num = deltaTime * 1000f;
float num2 = 1f / deltaTime;
string text = $"{num:0.0} ms \n{num2:0.} fps";
targetText.text = text;
}
}
}