using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class ErrowView : MonoBehaviour {
//错误详情
private List<String> m_logEntries = new List<String>();
//是否显示错误窗口
private bool m_IsVisible = false;
//窗口显示区域
private Rect m_WindowRect = new Rect(0, 0, Screen.width, Screen.height);
//窗口滚动区域
private Vector2 m_scrollPositionText = Vector2.zero;
private void Start()
{
// 关掉Log
#if !UNITY_EDITOR
Debug.unityLogger.logEnabled = false;
#endif
//监听错误
Application.logMessageReceived += (condition, stackTrace, type) =>
{
if (type == LogType.Exception || type == LogType.Error)
{
if (!m_IsVisible)
{
m_IsVisible = true;
}
m_logEntries.Add(string.Format("{0}\n{1}", condition, stackTrace));
}
};
Debug.LogError("momo");
Unity LogError UI
最新推荐文章于 2024-07-10 13:38:39 发布
本文详细探讨了Unity引擎中LogError函数的使用,以及如何将错误信息显示到用户界面(UI)上,帮助开发者更好地调试和解决游戏中遇到的问题。通过实例,解释了如何捕获和处理错误,以及如何利用Unity的UI系统创建自定义的日志视图。

最低0.47元/天 解锁文章
569

被折叠的 条评论
为什么被折叠?



