AVDebug.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using UnityEngine;
  2. using System.Collections;
  3. public class AssertionFailedException : UnityException
  4. {
  5. public AssertionFailedException(string message) : base(message)
  6. {
  7. }
  8. }
  9. /// <summary>
  10. /// This class is a wrapper for Debug.Log to easily strip out any logs in the final release versions.
  11. ///
  12. /// All the logs (.Log, .LogWarning, .LogError) will be output in the console if:
  13. /// - it is played inside the editor,
  14. /// - or DEBUG scripting define symbol is used,
  15. /// - or LOG_ALL scripting define symbol is used
  16. ///
  17. /// We can filter out the .Logs and keep Warnings and Errors by using the LOG_WARN_ERROR scripting define symbol
  18. /// We can keep only the Error logs by using the LOG_ERROR_ONLY scripting define symbol
  19. ///
  20. /// E.g. This gives us the flexibility to create a release with Warning and Errors by just using the LOG_WARN_ERROR
  21. /// scripting define symbol
  22. /// </summary>
  23. public class AVDebug
  24. {
  25. [System.Diagnostics.Conditional("DEBUG"),
  26. System.Diagnostics.Conditional("LOG_ALL"),
  27. System.Diagnostics.Conditional("UNITY_EDITOR")]
  28. public static void Log(object msg)
  29. {
  30. //Debug.Log(msg);
  31. }
  32. [System.Diagnostics.Conditional("DEBUG"),
  33. System.Diagnostics.Conditional("LOG_ALL"),
  34. System.Diagnostics.Conditional("UNITY_EDITOR")]
  35. public static void Log(object msg, Object context)
  36. {
  37. //Debug.Log(msg, context);
  38. }
  39. [System.Diagnostics.Conditional("DEBUG"),
  40. System.Diagnostics.Conditional("LOG_ALL"),
  41. System.Diagnostics.Conditional("LOG_WARN_ERROR"),
  42. System.Diagnostics.Conditional("UNITY_EDITOR")]
  43. public static void LogWarning(object msg)
  44. {
  45. //Debug.LogWarning(msg);
  46. }
  47. [System.Diagnostics.Conditional("DEBUG"),
  48. System.Diagnostics.Conditional("LOG_ALL"),
  49. System.Diagnostics.Conditional("LOG_WARN_ERROR"),
  50. System.Diagnostics.Conditional("UNITY_EDITOR")]
  51. public static void LogWarning(object msg, Object context)
  52. {
  53. //Debug.LogWarning(msg, context);
  54. }
  55. [System.Diagnostics.Conditional("DEBUG"),
  56. System.Diagnostics.Conditional("LOG_ALL"),
  57. System.Diagnostics.Conditional("LOG_WARN_ERROR"),
  58. System.Diagnostics.Conditional("LOG_ERROR_ONLY"),
  59. System.Diagnostics.Conditional("UNITY_EDITOR")]
  60. public static void LogError(object msg)
  61. {
  62. Debug.LogError(msg);
  63. }
  64. [System.Diagnostics.Conditional("DEBUG"),
  65. System.Diagnostics.Conditional("LOG_ALL"),
  66. System.Diagnostics.Conditional("LOG_WARN_ERROR"),
  67. System.Diagnostics.Conditional("LOG_ERROR_ONLY"),
  68. System.Diagnostics.Conditional("UNITY_EDITOR")]
  69. public static void LogError(object msg, Object context)
  70. {
  71. //Debug.LogError(msg);
  72. }
  73. [System.Diagnostics.Conditional("DEBUG")]
  74. public static void Assert(bool condition, string message)
  75. {
  76. if (!condition)
  77. {
  78. //throw new AssertionFailedException(message);
  79. }
  80. }
  81. }