Skip to content

Instantly share code, notes, and snippets.

@rubit0
Last active March 5, 2021 17:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubit0/daf609038b139f3848e7b1c39b74b1ea to your computer and use it in GitHub Desktop.
Save rubit0/daf609038b139f3848e7b1c39b74b1ea to your computer and use it in GitHub Desktop.
Debug build only debug logging.
public static class DevDebug
{
[Conditional("UNITY_EDITOR")]
[Conditional("DEBUG")]
public static void Log(string message, UnityEngine.Object context = null)
{
if (context != null)
{
Debug.Log(message, context);
}
else
{
Debug.Log(message);
}
}
[Conditional("UNITY_EDITOR")]
[Conditional("DEBUG")]
public static void LogWarning(string message, UnityEngine.Object context = null)
{
if (context != null)
{
Debug.LogWarning(message, context);
}
else
{
Debug.LogWarning(message);
}
}
[Conditional("UNITY_EDITOR")]
[Conditional("DEBUG")]
public static void LogError(string message, UnityEngine.Object context = null)
{
if (context != null)
{
Debug.LogError(message, context);
}
else
{
Debug.LogError(message);
}
}
[Conditional("UNITY_EDITOR")]
[Conditional("DEBUG")]
public static void LogException(Exception ex, UnityEngine.Object context = null)
{
if (context != null)
{
Debug.LogException(ex, context);
}
else
{
Debug.LogException(ex);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment