using System.Collections; using System.Collections.Generic; using UnityEngine; public class DebugFrame : MonoBehaviour { [SerializeField] private UnityEngine.UI.Text mText; /// 当前帧数 private int nFrameCount = 60; /// 统计时间 private int nStartSunTime = 0; /// 统计中的值 private int nFrameSunIng = 0; /// 渲染帧函数 void Update() { if (CStaticMethod.SystemAfterTime() - nStartSunTime >= 1000) { nFrameCount = nFrameSunIng; nStartSunTime = CStaticMethod.SystemAfterTime(); nFrameSunIng = 0; } else { nFrameSunIng++; } } private void LateUpdate() { Refresh(); } private void Refresh() { if (nFrameCount >= 40) { mText.color = Color.white; } else if (nFrameCount >= 30) { mText.color = Color.green; } else { mText.color = Color.red; } mText.text = "" + nFrameCount; } }