DebugMy.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. private static string sdkVersion = "";
  9. private static string SdkVersion {
  10. get {
  11. if (sdkVersion == "") {
  12. sdkVersion = API_Module_SDKVersion.Version;
  13. }
  14. return sdkVersion;
  15. }
  16. }
  17. public static void Log(string msg, object o, bool current = false,bool all = false) {
  18. // return;
  19. if(all == true) {
  20. isShowNormalLog = true;
  21. }
  22. if(isShowNormalLog == false && current == false)
  23. return;
  24. Tag = "[ SDK:"+ SdkVersion + " ][ FrameCount:" + Time.frameCount + " ]";
  25. if(o == null) {
  26. if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) {
  27. Debug.Log(Tag + msg);
  28. } else {
  29. Console.WriteLine(Tag + msg);
  30. }
  31. } else {
  32. if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) {
  33. Debug.Log(Tag + "[" + o.GetType().ToString() + "]: " + msg);
  34. } else {
  35. Console.WriteLine(Tag + "[" + o.GetType().ToString() + "]: " + msg);
  36. }
  37. }
  38. }
  39. public static void LogError(string msg, object o) {
  40. if(isShowErrorLog == false)
  41. return;
  42. Tag = "[ SDK:" + SdkVersion + " ][ FrameCount:" + Time.frameCount + " ]";
  43. if(o == null) {
  44. if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) {
  45. Debug.Log(Tag + msg);
  46. } else {
  47. Console.WriteLine(Tag + msg);
  48. }
  49. } else {
  50. if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) {
  51. Debug.Log(Tag + "[" + o.GetType().ToString() + "]: " + msg);
  52. } else {
  53. Console.WriteLine(Tag + "[" + o.GetType().ToString() + "]: " + msg);
  54. }
  55. }
  56. }
  57. }
  58. }