using UnityEngine; using System.Collections; using UnityEngine.UI; public class FPS : MonoBehaviour { [SerializeField] Text m_Text; public float updateInterval = 0.5F; private float lastInterval; private int frames = 0; private float fps; void Start() { lastInterval = Time.realtimeSinceStartup; frames = 0; } void LateUpdate() { ++frames; float timeNow = Time.realtimeSinceStartup; if (timeNow > lastInterval + updateInterval) { fps = frames / (timeNow - lastInterval); frames = 0; lastInterval = timeNow; if (m_Text != null) { m_Text.text = fps.ToString("F1"); } } } }