DebugMy.cs 2.4 KB

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