环境:Unity开发时会有很多的Debug.log输出测试
问题:最后游戏发布的时候,不希望在Produce发布环境也输出大量的日志,官方目前也没有正统的做法。
解决方法1: 重新封装
将Debug.log重新封装,自己添加开关。
using UnityEngine;
using System.Collections;
public class Debuger {
static public bool EnableLog = false;
static public void Log(object message)
{
Log(message,null);
}
static public void Log(object message, Object context)
{
if(EnableLog)
{
Debug.Log(message,context);
}
}
static public void LogError(object message)
{
LogError(message,null);
}
static public void LogError(object message, Object context)
{
if(EnableLog)
{
Debug.LogError(message,context);
}
}
static public void LogWarning(object message)
{
LogWarning(message,null);
}
static public void LogWarning(object message, Object context)
{
if(EnableLog)
{
Debug.LogWarning(message,context);
}
}
}