添加内容,不挂载:
using System.Diagnostics;
namespace UnityEngine
{
public static class DebugLog
{
[Conditional("EnableLog")]
public static void Logger(this object obj, string msg)
{
Debug.Log("<color=red>"+msg+"</color>");
}
}
}
其他地方使用:
using UnityEngine;
void Start() {
DebugLog.Logger(this.gameObject,"TEST");
}
tips:
progectSettings->player->otherSettings->scripting define symbols 填入限制字段,无该字段则不会有显示Log。