This repository has been archived on 2026-01-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
SH-INT/Assets/Scripts/UI_FPSCounter.cs
정영민 f4cf556cde update
2025-02-20 10:30:18 +09:00

38 lines
872 B
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
namespace SHINT.UI
{
public class UI_FPSCounter : MonoBehaviour
{
TextMeshProUGUI counter;
float frames = 0f;
float timeElap = 0f;
float frametime = 0;
void Update()
{
frames++;
timeElap += Time.unscaledDeltaTime; //frame time 더하기
//1초간의 평균 값 나타내기
if (timeElap > 1f)
{
frametime = timeElap / (float)frames;
timeElap -= 1f;
UpdateText();
frames = 0;
}
}
void UpdateText()
{
counter.text = string.Format(
"FPS : {0}, FrameTime : {1:F2} ms",
frames, frametime * 1000.0f);
}
}
}