Created
May 31, 2019 07:15
-
-
Save kitasenjudesign/61b54fe1ef0d93d9190b1511c3037966 to your computer and use it in GitHub Desktop.
simple fps counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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