ManaLog.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 Random = UnityEngine.Random;
  9. public class ManaLog : MonoBehaviour
  10. {
  11. #region 变量
  12. private static bool Lock;
  13. private static Text Lab;
  14. private static List<string> TextList;
  15. #endregion
  16. private void Awake()
  17. {
  18. Lab = ManaReso.Get<Text>("E_ScrrLab");
  19. Initializer.RegistValue += RegistValue;
  20. }
  21. private static void RegistValue()
  22. {
  23. TextList = new List<string>();
  24. }
  25. public static void Log(string message)
  26. {
  27. if (Lab)
  28. {
  29. if (Lock)
  30. {
  31. TextList.Add('\n' + message);
  32. }
  33. else
  34. {
  35. Lab.text += '\n' + message;
  36. }
  37. }
  38. }
  39. public static void Throw(string message = "Exception")
  40. {
  41. Lab.text += string.Format("\n<color=red>{0}</color>", message);
  42. }
  43. public static void LockBtn()
  44. {
  45. if (Lock)
  46. {
  47. for (int i = 0; i < TextList.Count; i++)
  48. {
  49. Lab.text += TextList[i];
  50. }
  51. ManaReso.SetText("E_LockLab", "固定");
  52. }
  53. else
  54. {
  55. ManaReso.SetText("E_LockLab", "解锁");
  56. }
  57. Lock = !Lock;
  58. }
  59. }