DebugMy.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using UnityEngine;
  3. namespace SC.XR.Unity {
  4. public class DebugMy {
  5. static string Tag ;
  6. public static bool isShowNormalLog = false;
  7. public static bool isShowErrorLog = true;
  8. public static void Log(string msg, object o, bool current = false,bool all = false) {
  9. if(all == true) {
  10. isShowNormalLog = true;
  11. }
  12. if(isShowNormalLog == false && current == false)
  13. return;
  14. Tag = "[ FrameCount:" + Time.frameCount + " ]";
  15. if(o == null) {
  16. if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) {
  17. Debug.Log(Tag + msg);
  18. } else {
  19. Console.WriteLine(Tag + msg);
  20. }
  21. } else {
  22. if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) {
  23. Debug.Log(Tag + "[" + o.GetType().ToString() + "]: " + msg);
  24. } else {
  25. Console.WriteLine(Tag + "[" + o.GetType().ToString() + "]: " + msg);
  26. }
  27. }
  28. }
  29. public static void LogError(string msg, object o) {
  30. if(isShowErrorLog == false)
  31. return;
  32. Tag = "[ FrameCount:" + Time.frameCount + " ]";
  33. if(o == null) {
  34. if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) {
  35. Debug.Log(Tag + msg);
  36. } else {
  37. Console.WriteLine(Tag + msg);
  38. }
  39. } else {
  40. if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) {
  41. Debug.Log(Tag + "[" + o.GetType().ToString() + "]: " + msg);
  42. } else {
  43. Console.WriteLine(Tag + "[" + o.GetType().ToString() + "]: " + msg);
  44. }
  45. }
  46. }
  47. }
  48. }