Files
fps-citybuild-unity/Assets/Scripts/FPSCounter.cs
2021-09-29 18:47:21 +02:00

22 lines
478 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FPSCounter : MonoBehaviour
{
public TMPro.TextMeshProUGUI fpsText;
public float deltaTime;
void Start()
{
fpsText = gameObject.GetComponent<TMPro.TextMeshProUGUI>();
}
void Update()
{
deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
float fps = 1.0f / deltaTime;
fpsText.text = Mathf.Ceil(fps).ToString() + "FPS";
}
}