/*
*FileName: MT_Debug.cs
*Author: MinTao
*Date: 2021/12/21 11:56:18
*UnityVersion: 2020.3.0f1c1
*Description:
*/
using System.Collections.Generic;
public static class MT_Debug
{
/// <summary>
/// 可否打印
/// </summary>
public static bool Logable = true;
/// <summary>
/// 打印颜色
/// </summary>
public enum COLOR
{
/// <summary>
/// 白色
/// </summary>
WHITE,
/// <summary>
/// 红色
/// </summary>
RED,
/// <summary>
/// 黄色
/// </summary>
YELLOW,
/// <summary>
/// 绿色
/// </summary>
GREEN,
/// <summary>
/// 橘色
/// </summary>
ORANGE,
/// <summary>
/// 灰色
/// </summary>
GRAY,
/// <summary>
/// 浅蓝色
/// </summary>
BABYBLUE,
}
static readonly Dictionary<COLOR, string> ColorType = new Dictionary<COLOR, string>
{
{COLOR.WHITE, "#FFFFFF"},
{COLOR.RED, "#FF0000"},
{COLOR.YELLOW, "#FFFF00"},
{COLOR.GREEN, "#00FF00"},
{COLOR.ORANGE, "#FFA500"},
{COLOR.GRAY, "#999999"},
{COLOR.BABYBLUE, "#00EEEE"},
};
private static string SetColor(this string str, COLOR color)
{
str = string.Format("<color={0}>{1}</color>", ColorType[color], str);
return str;
}
/// <summary>
/// 打印
/// </summary>
/// <param name="str">打印信息</param>
public static void Log(params object[] str)
{
if (!Logable)
{
return;
}
string log = string.Empty;
for (int i = 0; i < str.Length; i++)
{
if (i == str.Length - 1 && i > 0)
{
log += str[i];
}
else
{
log += str[i] + " ";
}
}
if (log == string.Empty)
{
log = ">>>>>>>>>>>>>>>>>>>>>>>>";
}
UnityEngine.Debug.Log(log);
}
/// <summary>
/// 打印
/// </summary>
/// <param name="color">打印颜色</param>
/// <param name="str">打印信息</param>
public static void Log(COLOR color, params object[] str)
{
if (!Logable)
{
return;
}
string log = string.Empty;
for (int i = 0; i < str.Length; i++)
{
if (i == str.Length - 1 && i > 0)
{
log += str[i];
}
else
{
log += str[i] + " ";
}
}
if (log == string.Empty)
{
log = ">>>>>>>>>>>>>>>>>>>>>>>>";
}
UnityEngine.Debug.Log(log.SetColor(color));
}
/// <summary>
/// 换行打印
/// </summary>
/// <param name="str">打印信息</param>
public static void LogLine(params object[] str)
{
if (!Logable)
{
return;
}
string log = string.Empty;
for (int i = 0; i < str.Length; i++)
{
if (i == str.Length - 1 && i > 0)
{
log += str[i];
}
else
{
log += str[i] + "\n";
}
}
if (log == string.Empty)
{
log = ">>>>>>>>>>>>>>>>>>>>>>>>";
}
UnityEngine.Debug.Log(log);
}
/// <summary>
/// 换行打印
/// </summary>
/// <param name="color">打印颜色</param>
/// <param name="str">打印信息</param>
public static void LogLine(COLOR color, params object[] str)
{
if (!Logable)
{
return;
}
string log = string.Empty;
for (int i = 0; i < str.Length; i++)
{
if (i == str.Length - 1 && i > 0)
{
log += str[i];
}
else
{
log += str[i] + "\n";
}
}
if (log == string.Empty)
{
log = ">>>>>>>>>>>>>>>>>>>>>>>>";
}
UnityEngine.Debug.Log(log.SetColor(color));
}
/// <summary>
/// 打印错误
/// </summary>
/// <param name="str">打印信息</param>
public static void LogError(params object[] str)
{
if (!Logable)
{
return;
}
string log = string.Empty;
for (int i = 0; i < str.Length; i++)
{
if (i == str.Length - 1 && i > 0)
{
log += str[i];
}
else
{
log += str[i] + " ";
}
}
if (log == string.Empty)
{
log = ">>>>>>>>>>>>>>>>>>>>>>>>";
}
UnityEngine.Debug.Log(log.SetColor(COLOR.RED));
}
/// <summary>
/// 打印警告
/// </summary>
/// <param name="str">打印信息</param>
public static void LogWarning(params object[] str)
{
if (!Logable)
{
return;
}
string log = string.Empty;
for (int i = 0; i < str.Length; i++)
{
if (i == str.Length - 1 && i > 0)
{
log += str[i];
}
else
{
log += str[i] + " ";
}
}
if (log == string.Empty)
{
log = ">>>>>>>>>>>>>>>>>>>>>>>>";
}
UnityEngine.Debug.Log(log.SetColor(COLOR.YELLOW));
}
}
04-25
01-04
373
08-08
3033