FPSView.cs 519 B

12345678910111213141516171819202122232425
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class FPSView : MonoBehaviour
  6. {
  7. private Text _text;
  8. private void Start()
  9. {
  10. _text = GetComponent<Text>();
  11. StartCoroutine(CUpdate());
  12. }
  13. private IEnumerator CUpdate()
  14. {
  15. while (true)
  16. {
  17. float FPS = 1 / Time.deltaTime;
  18. _text.text = "FPS: " + FPS.ToString("F0");
  19. yield return new WaitForSeconds(0.1f);
  20. }
  21. }
  22. }