Keywords: Unity, Basic Usage

C# Script:

using UnityEngine;
using System.Collections;

public class MyLog : MonoBehaviour
{
    string myLog;
    Queue myLogQueue = new Queue();

    void Start()
    {
        Debug.Log("Log1");
        Debug.Log("Log2");
        Debug.Log("Log3");
        Debug.Log("Log4");
    }

    void OnEnable ()
    {
        Application.logMessageReceived += HandleLog;
    }

    void OnDisable ()
    {
        Application.logMessageReceived -= HandleLog;
    }

    void HandleLog(string logString, string stackTrace, LogType type)
    {
        myLog = logString;
        string newString = "\n [" + type + "] : " + myLog;
        myLogQueue.Enqueue(newString);
        if (type == LogType.Exception)
        {
            newString = "\n" + stackTrace;
            myLogQueue.Enqueue(newString);
        }
        myLog = string.Empty;
        foreach(string mylog in myLogQueue)
        {
            myLog += mylog;
        }
    }

    void OnGUI ()
    {
        GUILayout.Label(myLog);
    }
}

Origin:
Print debug.log to screen? C#
https://answers.unity.com/questions/1020051/print-debuglog-to-screen-c.html


I love you not for whom you are, but who i am when i'm by your side. ― Gabriel García Márquez