Skip to content

Instantly share code, notes, and snippets.

@kitasenjudesign
Created May 31, 2019 07:15
Show Gist options
  • Save kitasenjudesign/61b54fe1ef0d93d9190b1511c3037966 to your computer and use it in GitHub Desktop.
Save kitasenjudesign/61b54fe1ef0d93d9190b1511c3037966 to your computer and use it in GitHub Desktop.
simple fps counter
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FPSCounter : MonoBehaviour{
private int _count = 0;
private int _total = 0;
private GUIStyle _style;
void Start(){
_StartTimer();
}
void _StartTimer(){
_total=_count;
_count=0;
Invoke("_StartTimer", 1f);
}
private void OnGUI()
{
if(_style==null){
_style = new GUIStyle();
_style.fontSize = 24;
_style.alignment = TextAnchor.UpperRight;
_style.normal.textColor = Color.blue;
}
GUI.Label(new Rect(Screen.width-205, 0, 200, 100), "FPS "+_total, _style);
}
void Update(){
_count++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment