1- Create a "Canvas" and add a "Text" and name it "FPS"
2- Create a script and name it "fpsCounter"
3- Attach "fpsCounter" script to "FPS" text
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class fpsCounter : MonoBehaviour
{
private float countFps = 0;
private float currentFpsTime = 0;
private float fpsShowPeriod = 1;
private Text gameFPS;
private void Start()
{
gameFPS = GetComponent<Text>();
}
void Update()
{
currentFpsTime = currentFpsTime + Time.deltaTime;
countFps = countFps + 1;
if (currentFpsTime > fpsShowPeriod)
{
gameFPS.text = countFps.ToString();
currentFpsTime = 0;
countFps = 0;
}
}
}
Hiç yorum yok:
Yorum Gönder