Files
findthesource/Assets/Scripts/fps.cs

23 lines
594 B
C#
Raw Normal View History

2022-11-11 13:42:40 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
2022-11-11 19:19:54 +01:00
using System.Threading;
2022-11-11 13:42:40 +01:00
public class fps : MonoBehaviour
{
public TMP_Text fpsText; //ideiglenesen megvaltoztatva az uzenet boxra!!
2022-11-11 19:19:54 +01:00
[SerializeField] private float _hudRefreshRate = 1f;
private float _timer;
2022-11-11 13:42:40 +01:00
// Update is called once per frame
void Update()
{
2022-11-11 19:19:54 +01:00
if (Time.unscaledTime > _timer) {
int fps = (int)(1f / Time.unscaledDeltaTime);
fpsText.text = "FPS: " + fps;
_timer = Time.unscaledTime + _hudRefreshRate;
}
2022-11-11 13:42:40 +01:00
}
}