LogManager.cs 920 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. namespace MartellController
  6. {
  7. /// <summary>
  8. /// 日志管理器
  9. /// </summary>
  10. public class LogManager : MonoBehaviour
  11. {
  12. public static LogManager Instance;
  13. private static Text TextLog;
  14. // ==================================================
  15. private void Awake()
  16. {
  17. Instance = this;
  18. TextLog = GameObject.Find("Text - Log").GetComponent<Text>();
  19. }
  20. public static void Log(string logMessage)
  21. {
  22. string logCache = $"Log >>> {logMessage}...[<color=green>OK</color>]";
  23. TextLog.text += "\n" + logCache;
  24. Debug.Log(logCache);
  25. return;
  26. }
  27. public static void ErrorLog(string logMessage)
  28. {
  29. string logCache = $"Log >>> {logMessage}...[<color=red>ER</color>]";
  30. TextLog.text += "\n" + logCache;
  31. Debug.Log(logCache);
  32. }
  33. }
  34. }