using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ErrorDisplay : MonoBehaviour
{
public TextMesh logError;
internal void OnEnable()
{
Application.logMessageReceived += HandleLog;
}
private void Awake()
{
DontDestroyOnLoad(this.gameObject);
}
internal void OnDisable()
{
Application.logMessageReceived -= HandleLog;
}
private string m_logs;
/// <summary>
///
/// </summary>
/// <param name="logString">错误信息</param>
/// <param name="stackTrace">跟踪堆栈</param>
/// <param name="type">错误类型</param>
void HandleLog(string logString, string stackTrace, LogType type = LogType.Error)
{
if (type == LogType.Error)
{
logError.color = Color.red;
}
else if (type == LogType.Warning)
{
logError.color = Color.yellow;
}
else
{
logError.color = Color.white;
}
m_logs = logString + "\n";
}
public bool Log;
private Vector2 m_scroll;
//internal void OnGUI()
//{
// if (!Log)
// return;
// m_scroll = GUILayout.BeginScrollView(m_scroll);
// GUILayout.Label(m_logs);
// GUILayout.EndScrollView();
//}
void Update()
{
logError.text = m_logs;
}
}