Global FPS

This commit is contained in:
2025-09-20 13:30:48 -07:00
parent f3bf3b694b
commit 8f41451bcb
7 changed files with 305 additions and 384 deletions

View File

@@ -0,0 +1,36 @@
using TMPro;
using UnityEngine;
[RequireComponent(typeof(TMP_Text))]
public class GlobalFPSText : MonoBehaviour
{
private TMP_Text text;
private float timer;
private int frames;
private float fps;
void Awake()
{
if (FindObjectsByType<GlobalFPSText>(FindObjectsSortMode.None).Length > 1)
{
Destroy(gameObject.transform.parent.gameObject);
return;
}
DontDestroyOnLoad(transform.parent.gameObject);
text = GetComponent<TMP_Text>();
}
void Update()
{
if (!BazookaManager.Instance.GetSettingShowFPS() && text.text != "") text.text = "";
frames++;
timer += Time.unscaledDeltaTime;
if (timer >= 0.25f)
{
fps = frames / timer;
text.text = "FPS: " + Mathf.RoundToInt(fps);
frames = 0;
timer = 0;
}
}
}