using System.Collections.Generic;
using UnityEngine;
namespace Miss
{
public enum LogEnum
{
None = 1,
All,
Log,
LogError
}
public class ColorDefine
{
private Dictionary<ColorType, string> ColorDic = new Dictionary<ColorType, string>()
{
[ColorType.LanSe] = "#0000FF",
[ColorType.LanZiSe] = "#9F5F9F",
[ColorType.HongSe] = "#FF0000",
[ColorType.ShanHuHong] = "#FF7F00",
[ColorType.MuDanHong] = "#FF00FF",
[ColorType.HuangSe] = "#FFFF00",
[ColorType.ShenLv] = "#00FF00",
[ColorType.JinSe] = "#CD7F32",
[ColorType.LiangJinSe] = "#D9D919",
};
public string this[ColorType type]
{
get { return ColorDic[type]; }
}
}
public enum ColorType
{
None = 0,
#region 蓝色
LanSe,
LanZiSe,
#endregion
#region 红色
HongSe,
ShanHuHong,
MuDanHong,
#endregion
#region 黄色
HuangSe,
#endregion
#region 绿色
ShenLv,
#endregion
#region 金色
JinSe,
LiangJinSe
#endregion
}
public static class LogUtilits
{
public static LogEnum LogType = LogEnum.All;
private static ColorDefine m_ColorDefine = new ColorDefine();
public static void LogErrorObjIsNull()
{
Debug.LogError("对象为空,请检查");
}
public static void LogErrorCountIsZero()
{
Debug.LogError("容量数量为0,请检查");
}
public static void LogFormat(string content, params string[] args)
{
if (LogType == LogEnum.All || LogType == LogEnum.Log)
{
Debug.LogFormat(content, args);
}
}
public static void LogErrorFormat(string content, params string[] args)
{
if (LogType == LogEnum.All || LogType == LogEnum.LogError)
{
Debug.LogErrorFormat(content, args);
}
}
public static void LogColorStr(string content, ColorType type = ColorType.None)
{
if (LogType == LogEnum.All || LogType == LogEnum.Log)
{
string str = content;
if (type != ColorType.None)
{
string colorCode = m_ColorDefine[type];
str = $": <color={colorCode}>{content}</color>";
}
UnityEngine.Debug.Log(str);
}
}
}
}