1.实现一个方法如下带三个参数,第一个为*错误信息*第二个为错误代码帮助辅助详细信息,第三个为输出Log类型共5中类型如下实例代码,给text1和text2赋值并让text1和text2显示出来就看到效果了
private void Logggg(string s, string b, LogType ll)
{
switch (ll)
{
case LogType.Error:
Text1.text = "Error";
Text2.text = "Error";
Text1.text += s;
Text2.text += b;
break;
case LogType.Assert:
Text1.text = "Assert";
Text2.text = "Assert";
Text1.text += s;
Text2.text += b;
break;
case LogType.Warning:
Text1.text = "Warning";
Text2.text = "Warning";
Text1.text += s;
Text2.text += b;
break;
case LogType.Log:
Text1.text = "Log";
Text2.text = "Log";
Text1.text += s;
Text2.text += b;
Debug.Log(s);
break;
case LogType.Exception:
Text1.text = "Exception";
Text2.text = "Exception";
Text1.text += s;
Text2.text += b;
break;
}
}
2.在给这个方法绑定到unity输出日志的事件委托上这里我放在Awake中进行绑定。
private void Awake()
{
Application.logMessageReceived += Logggg;
}
我的一个执行效果延时