Fps Counter Unity Code Example


Example: unity fps counter


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class FpsScript : MonoBehaviour
{
[SerializeField] private Text fpsText;
[SerializeField] private float hudRefreshRate = 1f;

private float timer;

private void Update()
{
if(Time.unscaledTime > timer)
{
int fps = (int)(1f / Time.unscaledDeltaTime);
fpsText.text = fps + " FPS on " + SceneManager.GetActiveScene().path;
timer = Time.unscaledTime + hudRefreshRate;
}
}
}

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable