30 lines
644 B
C#
30 lines
644 B
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class ConsolePrinter : MonoBehaviour
|
|
{
|
|
static string historyOutput = "";
|
|
|
|
public TMP_Text textBox;
|
|
void OnEnable()
|
|
{
|
|
Application.logMessageReceived += Log;
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
Application.logMessageReceived -= Log;
|
|
}
|
|
|
|
private void Log(string logString, string stackTrace, LogType type)
|
|
{
|
|
historyOutput = Time.fixedTime + ": " + logString + "\n" + historyOutput;
|
|
if (historyOutput.Length > 5000)
|
|
{
|
|
historyOutput = historyOutput[..4000];
|
|
}
|
|
|
|
textBox.text = historyOutput;
|
|
}
|
|
} |