12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class DebugFrame : MonoBehaviour {
- [SerializeField]
- private UnityEngine.UI.Text mText;
- /// <summary>当前帧数</summary>
- private int nFrameCount = 60;
- /// <summary>统计时间</summary>
- private int nStartSunTime = 0;
- /// <summary>统计中的值</summary>
- private int nFrameSunIng = 0;
- /// <summary>渲染帧函数</summary>
- 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;
- }
- }
|