对debug消息的封装,便于项目后期的隐藏输出多余信息
using System;
using UnityEngine;
public class Debuger
{
public static bool EnableLogger = true;
public static void Log(object message)
{
if (EnableLogger) Debug.Log(message);
}
public static void Log(object message, UnityEngine.Object context)
{
if (EnableLogger) Debug.Log(message, context);
}
public static void LogError(object message)
{
if (EnableLogger) Debug.LogError(message);
}
public static void LogError(object message, UnityEngine.Object context)
{
if (EnableLogger) Debug.LogError(message, context);
}
public static void LogErrorFormat(string format, params object[] args)
{
if (EnableLogger) Debug.LogErrorFormat(format, args);
}
public static void LogErrorFormat(UnityEngine.Object context,
string format, params object[] args)
{
if (EnableLogger) Debug.LogErrorFormat(context, format, args);
}
public static void LogException(Exception exception)
{
if (EnableLogger) Debug.LogException(exception);
}
public static void LogException(Exception exception,
UnityEngine.Object context)
{
if (EnableLogger) Debug.LogException(exception, context);
}
public static void LogFormat(string format, params object[] args)
{
if (EnableLogger) Debug.LogFormat(format, args);
}
public static void LogFormat(UnityEngine.Object context,
string format, params object[] args)
{
if (EnableLogger) Debug.LogFormat(context, format, args);
}
public static void LogWarning(object message)
{
if (EnableLogger) Debug.LogWarning(message);
}
/*
* param 当你在控制台点击输出的消息的时候,到上下文物体(context)的一个连接将被绘制。如果你想知道在那个对象上发生了警告,这是非常有用的。
*/
public static void LogWarning(object message,
UnityEngine.Object context)
{
if (EnableLogger) Debug.LogWarning(message, context);
}
public static void LogWarningFormat(string format,
params object[] args)
{
if (EnableLogger) Debug.LogWarningFormat(format, args);
}
public static void LogWarningFormat(UnityEngine.Object context,
string format, params object[] args)
{
if (EnableLogger) Debug.LogWarningFormat(context, format, args);
}
}
版权声明:本文为lq1340817945原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。