Logger.cs 914 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace Agora.Util
  4. {
  5. public class Logger
  6. {
  7. Text text;
  8. public Logger(Text text)
  9. {
  10. this.text = text;
  11. }
  12. public void UpdateLog(string logMessage)
  13. {
  14. Debug.Log(logMessage);
  15. string srcLogMessage = text.text;
  16. if (srcLogMessage.Length > 400)
  17. {
  18. srcLogMessage = srcLogMessage.Substring(srcLogMessage.Length - 50);
  19. }
  20. srcLogMessage += "\r\n \r\n";
  21. srcLogMessage += logMessage;
  22. text.text = srcLogMessage;
  23. }
  24. public bool DebugAssert(bool condition, string message)
  25. {
  26. if (!condition)
  27. {
  28. UpdateLog(message);
  29. return false;
  30. }
  31. Debug.Assert(condition, message);
  32. return true;
  33. }
  34. }
  35. }