using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class fps : MonoBehaviour { private float m_UpdateShowDeltaTime;//更新帧率的时间间隔; private int m_FrameUpdate = 0;//帧数; public TMP_Text FPS_Text; float FPS; // Update is called once per frame void Update() { m_FrameUpdate++; m_UpdateShowDeltaTime += Time.deltaTime; if (m_UpdateShowDeltaTime >= 0.2) { FPS = m_FrameUpdate / m_UpdateShowDeltaTime; m_UpdateShowDeltaTime = 0; m_FrameUpdate = 0; } FPS_Text.text = "FPS:" + FPS.ToString(); } }