using System.Collections; using System.Collections.Generic; using UnityEngine; namespace BF { public class ShowFPS : MonoBehaviour { public float f_UpdateInterval = 0.5f; private float f_LastInterval; private int i_Frames = 0; private float f_Fps; void Start() { f_LastInterval = Time.realtimeSinceStartup; i_Frames = 0; } void OnGUI() { GUIStyle bb = new GUIStyle(); bb.normal.textColor = new Color(255, 0, 0); bb.fontSize = 40; GUI.Label(new Rect(0, 0, 200, 200), "FPS:" + f_Fps.ToString("f2"), bb); } void Update() { ++i_Frames; if (Time.realtimeSinceStartup > f_LastInterval + f_UpdateInterval) { f_Fps = i_Frames / (Time.realtimeSinceStartup - f_LastInterval); i_Frames = 0; f_LastInterval = Time.realtimeSinceStartup; } } } }