KITASENJU DESIGN BLOG

memo, html, javascript, unity

Simple FPS Counter

count frame every second.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FPSCounter : MonoBehaviour
{
    private int _counter=0;
    private float _time = 0;
    public int fps =0;
    public static int Fps=0;
    void Update()
    {
        _time+=Time.deltaTime;
        if(_time>1f){
            Fps = fps = _counter;
             _time=0;
            _counter=0;            
        }else{
            _counter++;
        }
    }
}

"FOOTER"