Optimized
This commit is contained in:
24
Assets/Game/Scripts/FPSCounter.cs
Normal file
24
Assets/Game/Scripts/FPSCounter.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class FPSCounter : MonoBehaviour
|
||||
{
|
||||
public int fps;
|
||||
public TMP_Text fpsTxt;
|
||||
|
||||
float t;
|
||||
public void Update ()
|
||||
{
|
||||
float current = 0;
|
||||
current = (int)(1f / Time.unscaledDeltaTime);
|
||||
fps = (int)current;
|
||||
if(t < 0.2f){
|
||||
t += Time.deltaTime;
|
||||
return;
|
||||
}
|
||||
fpsTxt.text = fps.ToString() + " FPS";
|
||||
t=0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user