2021년 4학년 1학기 기업연계프로젝트2 컴퓨터소프트웨어공학과 <원광투어팀> 팀장 : 송유진 팀원 : 김나영, 이경희, 한유진
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
898 B

5 years ago
  1. using UnityEngine;
  2. using TMPro;
  3. namespace Unity.FPS.UI
  4. {
  5. public class FramerateCounter : MonoBehaviour
  6. {
  7. [Tooltip("Delay between updates of the displayed framerate value")]
  8. public float PollingTime = 0.5f;
  9. [Tooltip("The text field displaying the framerate")]
  10. public TextMeshProUGUI UIText;
  11. float m_AccumulatedDeltaTime = 0f;
  12. int m_AccumulatedFrameCount = 0;
  13. void Update()
  14. {
  15. m_AccumulatedDeltaTime += Time.deltaTime;
  16. m_AccumulatedFrameCount++;
  17. if (m_AccumulatedDeltaTime >= PollingTime)
  18. {
  19. int framerate = Mathf.RoundToInt((float) m_AccumulatedFrameCount / m_AccumulatedDeltaTime);
  20. UIText.text = framerate.ToString();
  21. m_AccumulatedDeltaTime = 0f;
  22. m_AccumulatedFrameCount = 0;
  23. }
  24. }
  25. }
  26. }