Heroes_of_Hiis/Assets/Project Files/Scripts/Helar/ConsolePrinter.cs

30 lines
644 B
C#
Raw Normal View History

2022-03-28 07:08:54 +00:00
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;
}
}