StatisticData.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Sirenix.OdinInspector;
  5. namespace KairoEngine.Utilities.Statistics
  6. {
  7. public enum StatisticType
  8. {
  9. time,
  10. integer,
  11. text
  12. }
  13. [System.Serializable, HideMonoScript]
  14. public class StatisticData
  15. {
  16. [HorizontalGroup(180), HideLabel] public string title;
  17. [ShowIf("@category == StatisticType.time"), HorizontalGroup(), HideLabel, ShowInInspector] private float time;
  18. [ShowIf("@category == StatisticType.integer"), HorizontalGroup(), HideLabel, ShowInInspector] private int integer;
  19. [ShowIf("@category == StatisticType.text"), HorizontalGroup(), HideLabel, ShowInInspector] private string text;
  20. [HorizontalGroup(80), HideLabel] public StatisticType category;
  21. [HorizontalGroup(), HideLabel, Tooltip("Persistent Data?")] public bool persistent = false;
  22. public void AddTime(float t) => time += t;
  23. public void AddInteger(int n) => integer += n;
  24. public float GetTime() => time;
  25. public int GetInteger() => integer;
  26. public string GetText() => text;
  27. public void SetTime(float t) => time = t;
  28. public void SetInteger(int n) => integer = n;
  29. public void SetText(string t) => text = t;
  30. public void Reset()
  31. {
  32. time = 0f;
  33. integer = 0;
  34. text = "";
  35. }
  36. }
  37. }