Skip to content

Instantly share code, notes, and snippets.

@Naphier
Created October 11, 2015 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Naphier/14ec6040ffdd534b4af6 to your computer and use it in GitHub Desktop.
Save Naphier/14ec6040ffdd534b4af6 to your computer and use it in GitHub Desktop.
Replacement for Unity's debug so we can just shut it off for production
using UnityEngine;
/// <summary>
/// Replacement for Unity's debug so we can just shut it off for production
/// </summary>
public class NGDebug
{
private enum WarningLevel
{ all, warning, error, none }
private static WarningLevel warningLevel = WarningLevel.all;
public static void Log(object message)
{
if (warningLevel == WarningLevel.all)
Debug.Log(message.ToString());
}
public static void Log(object message, Object context)
{
if (warningLevel == WarningLevel.all)
Debug.Log(message.ToString(), context);
}
public static void LogWarning(object message)
{
if (warningLevel == WarningLevel.all || warningLevel == WarningLevel.warning )
Debug.LogWarning(message.ToString());
}
public static void LogWarning(object message, Object context)
{
if (warningLevel == WarningLevel.all || warningLevel == WarningLevel.warning)
Debug.LogWarning(message.ToString(), context);
}
public static void LogError(object message)
{
if (warningLevel == WarningLevel.all || warningLevel == WarningLevel.error)
Debug.LogError(message.ToString());
}
public static void LogError(object message, Object context)
{
if (warningLevel == WarningLevel.all || warningLevel == WarningLevel.error)
Debug.LogError(message.ToString(), context);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment