public class LogManager
{
// Fields
public static bool Debugstate; // Methods
public static void Log(string strText)
{
if (Debugstate)
{
Debug.Log(strText);
}
} public static void Log(string strText, Object context)
{
if (Debugstate)
{
Debug.Log(strText, context);
}
} public static void LogError(string strText)
{
if (Debugstate)
{
Debug.LogError(strText);
}
} public static void LogError(string strText, Object context)
{
if (Debugstate)
{
Debug.LogError(strText, context);
}
} public static void LogWarning(string strText)
{
if (Debugstate)
{
Debug.LogWarning(strText);
}
} public static void LogWarning(string strText, Object context)
{
if (Debugstate)
{
Debug.LogWarning(strText, context);
}
}
}
namespace Kola
{
using System;
using System.IO;
using System.Text;
using UnityEngine; public class KDebugHelp
{
public static bool Enable;
public static bool EnableKConsole; internal KDebugHelp()
{
} public static void Assert(bool flag, string format, params object[] param)
{
if (!flag)
{
PrintError(format, param);
}
} public static void DrawCenterRect(Vector2 center, Vector2 size, float duration, Color color)
{
Vector2 leftTop = new Vector2(center.x - (size.x * 0.5f), center.y + (size.y * 0.5f));
Vector2 rightBottom = new Vector2(center.x + (size.x * 0.5f), center.y - (size.y * 0.5f));
DrawRect(leftTop, rightBottom, duration, color);
} public static void DrawLine(Vector2 start, Vector2 end, float duration, Color color)
{
if (Enable)
{
Debug.DrawLine((Vector3) start, (Vector3) end, color, duration);
}
} public static void DrawPolygon(float duration, Color color, bool close, params Vector2[] pnts)
{
if (Enable && ((pnts != null) && (pnts.Length > )))
{
for (int i = ; i < pnts.Length; i++)
{
DrawLine(pnts[i - ], pnts[i], duration, color);
}
if (close)
{
DrawLine(pnts[pnts.Length - ], pnts[], duration, color);
}
}
} public static void DrawRect(Vector2 leftTop, Vector2 rightBottom, float duration, Color color)
{
if (Enable)
{
DrawLine(new Vector3(leftTop.x, leftTop.y, 0f), new Vector3(rightBottom.x, leftTop.y, 0f), duration, color);
DrawLine(new Vector3(leftTop.x, rightBottom.y, 0f), new Vector3(rightBottom.x, rightBottom.y, 0f), duration, color);
DrawLine(new Vector3(leftTop.x, leftTop.y, 0f), new Vector3(leftTop.x, rightBottom.y, 0f), duration, color);
DrawLine(new Vector3(rightBottom.x, leftTop.y, 0f), new Vector3(rightBottom.x, rightBottom.y, 0f), duration, color);
}
} public static void Error(string msg)
{
WriteLog2File("Error", msg);
if (Enable)
{
if (EnableKConsole)
{
}
Debug.LogError(msg);
}
} public static void Error(string format, params object[] param)
{
Error(string.Format(format, param));
} public static void Log(string msg)
{
if (Enable && !EnableKConsole)
{
Debug.Log(msg);
}
} public static void Log(string format, params object[] param)
{
Log(string.Format(format, param));
} public static void Print(string format, params object[] param)
{
Log(format, param);
} public static void PrintError(string format, params object[] param)
{
Error(format, param);
} public static void PrintWarning(string format, params object[] param)
{
Warning(format, param);
} public static void Warning(string msg)
{
if (Enable)
{
if (EnableKConsole)
{
}
Debug.LogWarning(msg);
}
} public static void Warning(string format, params object[] param)
{
Warning(string.Format(format, param));
} public static void WriteLog2File(string level, string msg)
{
using (FileStream stream = new FileStream(KAssertManager.ExternalPath + "Log.txt", FileMode.Append))
{
string s = string.Format("[{0}] [{1}] [{2}] \n", level, KUtil.GetSystemTime("HH:mm:ss"), msg);
byte[] bytes = Encoding.UTF8.GetBytes(s);
stream.Write(bytes, , bytes.Length);
stream.Flush();
}
}
}
}

最新文章

  1. 你写的Try...Catch真的有必要么?
  2. PHP常量、变量作用域详解(一)
  3. java.lang.Class&lt;T&gt; -- 反射机制
  4. HTTP协议 (四) 缓存
  5. INSTRUCTION CYCLE
  6. 数据结构之链表C语言实现以及使用场景分析
  7. 阿里云的ubuntu server 12.04 下安装jdk和tomcat
  8. 如何去除内联元素(inline-block元素)之间的间距(转载)
  9. Android Service学习之本地服务
  10. 无DLL线程注入
  11. &quot;xxxx&quot;.zip:这个压缩文件格式未知或者数据已经被损坏,打不开压缩文件,总出现这个提示的解决方法
  12. uva 10369
  13. vijos1067守望者的逃离
  14. Linux Kernel ‘write_tag_3_packet()’函数本地基于堆的缓冲区溢出漏洞
  15. git merge的recursive策略和merge-base
  16. linux入侵控制与痕迹清理
  17. Promise,Async,await简介
  18. PHP中对汉字进行UNICODE编码和解码的实现
  19. 初探WebSocket
  20. 【原创】C# war3 巨魔精灵 minimap

热门文章

  1. springboot 返回json格式数据的时间格式配置
  2. JAVA集合操作的利器:CollectionUtils
  3. Ajaxterm + nginx 实现一个简单的堡垒机
  4. MySQL存储IP地址
  5. mysql 文本搜索
  6. Python与数据结构[3] -&gt; 树/Tree[2] -&gt; AVL 平衡树和树旋转的 Python 实现
  7. 某dalao贼快的hash?
  8. [BZOJ 1072] 排列perm
  9. 10.1(java学习笔记)JDBC基本操作(连接,执行SQL语句,获取结果集)
  10. jQuery判断一个元素是否为另一个元素的子元素