2026-02-03 13:18:08 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class UpdateFpsUI : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private Text fpsText;
|
|
|
|
|
|
|
|
|
|
private float frameCount = 0;
|
|
|
|
|
private float deltaTime = 0f;
|
|
|
|
|
private float fps = 0f;
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2026-02-04 05:31:41 +00:00
|
|
|
Application.targetFrameRate = 120;
|
2026-02-03 13:18:08 +00:00
|
|
|
fpsText = transform.GetComponent<Text>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
frameCount++;
|
|
|
|
|
deltaTime += Time.unscaledDeltaTime;
|
|
|
|
|
if (deltaTime > 1)
|
|
|
|
|
{
|
|
|
|
|
fps = frameCount / deltaTime;
|
|
|
|
|
fpsText.text = $"fps : {Mathf.Round(fps)}";
|
|
|
|
|
|
|
|
|
|
frameCount = 0;
|
|
|
|
|
deltaTime = 0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|