DebugManager.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using UnityEngine.Serialization;
  4. using System;
  5. using System.Text;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using Sfs2X.Core;
  9. using Random = UnityEngine.Random;
  10. public class DebugManager : MonoBehaviour
  11. {
  12. #region Config
  13. public static Text DebugBugText
  14. {
  15. get
  16. {
  17. if (debugBugText == null)
  18. {
  19. DebugBugText = ResourceManager.Get<Text>(CanvasLabel.E_ScrrLab, false);
  20. }
  21. return debugBugText;
  22. }
  23. set { debugBugText = value; }
  24. }
  25. private static Text debugBugText;
  26. public int TextCounter;
  27. public float FrameRateTimer;
  28. #endregion
  29. public void Update()
  30. {
  31. FrameRateTimer += Time.deltaTime;
  32. TextCounter++;
  33. if (FrameRateTimer >= 1)
  34. {
  35. //Log($"当前帧率 {Counter} 目标帧率 {Application.targetFrameRate}");
  36. FrameRateTimer = 0;
  37. TextCounter = 0;
  38. }
  39. }
  40. public static void Log(string message)
  41. {
  42. if (DebugBugText == null)
  43. {
  44. return;
  45. }
  46. DebugBugText.text += '\n' + message;
  47. }
  48. public static void ResetAbilityAnim()
  49. {
  50. SkillRoot skillRoot = Manager.SkillDictionary["Ability2"];
  51. skillRoot.Level = 0;
  52. skillRoot.ItemStatus = SkillStatus.Lock;
  53. skillRoot = Manager.SkillDictionary["Ability3"];
  54. skillRoot.Level = 0;
  55. skillRoot.ItemStatus = SkillStatus.Lock;
  56. skillRoot = Manager.SkillDictionary["Ability4"];
  57. skillRoot.Level = 0;
  58. skillRoot.ItemStatus = SkillStatus.Lock;
  59. }
  60. public static void ResetGardenLevel(int level)
  61. {
  62. SkillRoot skillRoot = Manager.SkillDictionary["Ability1"];
  63. skillRoot.Level = level;
  64. if (level == 0)
  65. {
  66. skillRoot.itemStatus = SkillStatus.UnLock;
  67. }
  68. else
  69. {
  70. skillRoot.itemStatus = SkillStatus.Upgrade;
  71. }
  72. }
  73. public static void ResetVisitTutorial()
  74. {
  75. TutorialManager.visitTutorial = true;
  76. TutorialManager.VisitTutorial = true;
  77. }
  78. public static void TryCatch(Action tryAction, Action catchAction)
  79. {
  80. try
  81. {
  82. tryAction.Invoke();
  83. }
  84. catch (Exception)
  85. {
  86. catchAction.Invoke();
  87. }
  88. }
  89. public static void PrintKeysAndValuesOfBaseEvent(string seperator, BaseEvent baseEvent)
  90. {
  91. Debug.LogWarning(seperator);
  92. foreach (var key in baseEvent.Params.Keys)
  93. {
  94. Debug.Log("Key " + key);
  95. }
  96. foreach (var value in baseEvent.Params.Values)
  97. {
  98. Debug.Log("value " + value);
  99. }
  100. Debug.LogWarning(seperator);
  101. }
  102. }