FPSCounter.cs 431 B

1234567891011121314151617181920
  1. using System;
  2. using UnityEngine;
  3. public class FPSCounter : MonoBehaviour
  4. {
  5. private void Awake()
  6. {
  7. this.style.fontSize = 20;
  8. this.style.normal.textColor = Color.white;
  9. Application.targetFrameRate = 60;
  10. }
  11. private void OnGUI()
  12. {
  13. float num = 1f / Time.smoothDeltaTime;
  14. GUI.Label(new Rect(10f, 5f, 50f, 20f), num.ToString("#,##0.0 fps"), this.style);
  15. }
  16. private GUIStyle style = new GUIStyle();
  17. }