38 lines
872 B
C#
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);
|
|
}
|
|
}
|
|
} |