This commit is contained in:
2026-01-18 22:27:22 +08:00
parent 331ec8c8bf
commit 120b8cda26
9 changed files with 3269 additions and 14 deletions

View File

@@ -0,0 +1,44 @@
using System;
using TMPro;
using UnityEngine;
namespace NBF
{
public class FPSShower : MonoBehaviour
{
public TextMeshProUGUI TextFPS;
public float updateInterval = 0.2f; // 更新间隔(秒)
private float accum = 0;
private int frames = 0;
private float timeleft;
private void Awake()
{
Application.targetFrameRate = 300; // 设为极高值
}
public int FPS;
void Update()
{
timeleft -= Time.deltaTime;
accum += Time.timeScale / Time.deltaTime;
frames++;
if (timeleft <= 0.0f)
{
FPS = (int)(accum / frames);
timeleft = updateInterval;
accum = 0.0f;
frames = 0;
TextFPS.text = FPS.ToString();
}
}
}
}