显示unity的log

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;

    ///


    /// 
    ///

    /// 错误信息
    /// 跟踪堆栈
    /// 错误类型
    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;
    }
}

你可能感兴趣的:(unity,servlet,java,junit)