YmDebug.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //#if UNITY_IPHONE&&!UNITY_EDITOR
  2. using System;
  3. using UnityEngine;
  4. public class YmDebug
  5. {
  6. //TODO wait for the global debug
  7. static public bool EnableDebug = true;
  8. static public void Log (string context)
  9. {
  10. if (EnableDebug) {
  11. Debug.Log (context);
  12. }
  13. }
  14. /// Output the Class Name
  15. static public void Log (object obj, string context)
  16. {
  17. Log (string.Format("[{0}] {1}", obj.GetType().Name, context));
  18. }
  19. /// Log the message by Color - Green
  20. static public void LogCG (string context)
  21. {
  22. if (EnableDebug) {
  23. Debug.Log (string.Format("<color=Green>{0}</color>",context));
  24. }
  25. }
  26. /// Output the Class Name And Log the message by Color - Green
  27. static public void LogCG (object obj, string context)
  28. {
  29. LogCG (string.Format("[{0}] {1}", obj.GetType().Name, context));
  30. }
  31. /// Log the message by Color - Red
  32. static public void LogCR (string context)
  33. {
  34. if (EnableDebug) {
  35. Debug.Log (string.Format("<color=#d04545>{0}</color>",context));
  36. }
  37. }
  38. /// Output the Class Name And Log the message by Color - Red
  39. static public void LogCR (object obj, string context)
  40. {
  41. LogCR (string.Format("[{0}] {1}", obj.GetType().Name, context));
  42. }
  43. static public void LogWarning (string context)
  44. {
  45. if (EnableDebug) {
  46. Debug.LogWarning (context);
  47. }
  48. }
  49. static public void LogError (string context)
  50. {
  51. if (EnableDebug) {
  52. Debug.LogError (context);
  53. }
  54. }
  55. public static void LogException (Exception exception)
  56. {
  57. Debug.LogException (exception);
  58. }
  59. public static void LogException (Exception exception, UnityEngine.Object context)
  60. {
  61. Debug.LogException (exception, context);
  62. }
  63. public static void DrawLine (Vector3 start, Vector3 end)
  64. {
  65. Debug.DrawLine (start, end);
  66. }
  67. public static void DrawLine (Vector3 start, Vector3 end, UnityEngine.Color color)
  68. {
  69. Debug.DrawLine (start, end, color);
  70. }
  71. public static void DrawLine (Vector3 start, Vector3 end, Color color, float duration)
  72. {
  73. Debug.DrawLine (start, end, color, duration);
  74. }
  75. public static void DrawLine (Vector3 start, Vector3 end, Color color, float duration, bool depthTest)
  76. {
  77. Debug.DrawLine (start, end, color, duration, depthTest);
  78. }
  79. public static void DrawRay (Vector3 start, Vector3 dir)
  80. {
  81. Debug.DrawRay (start, dir);
  82. }
  83. public static void DrawRay (Vector3 start, Vector3 dir, Color color)
  84. {
  85. Debug.DrawRay (start, dir, color);
  86. }
  87. public static void DrawRay (Vector3 start, Vector3 dir, Color color, float duration)
  88. {
  89. Debug.DrawRay (start, dir, color, duration);
  90. }
  91. public static void DrawRay (Vector3 start, Vector3 dir, Color color, float duration, bool depthTest)
  92. {
  93. Debug.DrawRay (start, dir, color, duration, depthTest);
  94. }
  95. public static void Break ()
  96. {
  97. Debug.Break ();
  98. }
  99. public static void ClearDeveloperConsole ()
  100. {
  101. Debug.ClearDeveloperConsole ();
  102. }
  103. public static void DebugBreak ()
  104. {
  105. Debug.DebugBreak ();
  106. }
  107. }
  108. //#endif