DebugManager.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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>(ObjectLabel.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 ResetGardenLevel(int level)
  49. {
  50. SkillRoot skillRoot = Manager.SkillDictionary["Ability1"];
  51. skillRoot.Level = level;
  52. if (level == 0)
  53. {
  54. skillRoot.itemStatus = SkillStatus.UnLock;
  55. }
  56. else
  57. {
  58. skillRoot.itemStatus = SkillStatus.Upgrade;
  59. }
  60. }
  61. public static void ResetVisitTutorial()
  62. {
  63. TutorialManager.visitTutorial = true;
  64. TutorialManager.VisitTutorial = true;
  65. }
  66. public static void TryCatch(Action tryAction, Action catchAction)
  67. {
  68. try
  69. {
  70. tryAction.Invoke();
  71. }
  72. catch (Exception)
  73. {
  74. catchAction.Invoke();
  75. }
  76. }
  77. public static void PrintKeysAndValuesOfBaseEvent(string seperator, BaseEvent baseEvent)
  78. {
  79. Debug.LogWarning(seperator);
  80. foreach (var key in baseEvent.Params.Keys)
  81. {
  82. Debug.Log("Key " + key);
  83. }
  84. foreach (var value in baseEvent.Params.Values)
  85. {
  86. Debug.Log("value " + value);
  87. }
  88. Debug.LogWarning(seperator);
  89. }
  90. }