StatisticElapsedTime.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using KairoEngine.Utilities;
  5. using Sirenix.OdinInspector;
  6. using KairoEngine.Core;
  7. namespace KairoEngine.Utilities.Statistics
  8. {
  9. [HideMonoScript]
  10. public class StatisticElapsedTime : MonoBehaviour
  11. {
  12. public string statisticName = "";
  13. [ReadOnly] public string elapsedTime;
  14. [HorizontalGroup()] public bool unscaledDeltaTime = true;
  15. [HorizontalGroup()] public bool resetOnStart = true;
  16. void Start()
  17. {
  18. if(resetOnStart) Statistics.GetData(statisticName).Reset();
  19. }
  20. void Update()
  21. {
  22. if(unscaledDeltaTime)
  23. {
  24. Statistics.GetData(statisticName).AddTime(Time.unscaledDeltaTime);
  25. }
  26. else
  27. {
  28. Statistics.GetData(statisticName).AddTime(Time.deltaTime);
  29. }
  30. float time = Statistics.GetData(statisticName).GetTime();
  31. elapsedTime = KairoEngine.Core.Utilities.TimeToString(time);
  32. }
  33. }
  34. }