2022-09-21 05:40:58 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
namespace RimWorldAnimationStudio
|
|
|
|
|
{
|
|
|
|
|
public class ConsoleMessagesDialog : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public bool isExpanded = false;
|
|
|
|
|
public GameObject consoleWindow;
|
|
|
|
|
public Transform logContent;
|
|
|
|
|
public Text stackTrace;
|
|
|
|
|
public Text currentMessage;
|
|
|
|
|
public Text logMessagePrefab;
|
|
|
|
|
public int maxMessages = 500;
|
|
|
|
|
|
|
|
|
|
private int currentMessages = 0;
|
|
|
|
|
|
|
|
|
|
public void Start()
|
|
|
|
|
{
|
|
|
|
|
Application.logMessageReceived += LogMessage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ToggleExpand()
|
|
|
|
|
{
|
|
|
|
|
isExpanded = !isExpanded;
|
|
|
|
|
|
|
|
|
|
consoleWindow.SetActive(isExpanded);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LogMessage(string logString, string stackTrace, LogType type)
|
|
|
|
|
{
|
2022-10-19 02:57:43 +00:00
|
|
|
|
if (currentMessages > maxMessages) return;
|
|
|
|
|
currentMessages++;
|
2022-09-21 05:40:58 +00:00
|
|
|
|
|
|
|
|
|
currentMessage.text = logString;
|
|
|
|
|
|
|
|
|
|
Text logMessage = Instantiate(logMessagePrefab, logContent);
|
|
|
|
|
logMessage.text = logString;
|
|
|
|
|
|
|
|
|
|
logMessage.GetComponent<Button>().onClick.AddListener(delegate { OpenStackTrace(stackTrace); });
|
|
|
|
|
|
|
|
|
|
if (type == LogType.Warning)
|
|
|
|
|
{
|
2022-10-12 05:22:29 +00:00
|
|
|
|
currentMessage.color = Constants.ColorRichOrange;
|
|
|
|
|
logMessage.color = Constants.ColorRichOrange;
|
2022-09-21 05:40:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (type == LogType.Exception || type == LogType.Error)
|
|
|
|
|
{
|
|
|
|
|
currentMessage.color = Constants.ColorRed;
|
|
|
|
|
logMessage.color = Constants.ColorRed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
currentMessage.color = Constants.ColorDarkGrey;
|
|
|
|
|
logMessage.color = Constants.ColorDarkGrey;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OpenStackTrace(string stackTrace)
|
|
|
|
|
{
|
|
|
|
|
this.stackTrace.text = stackTrace;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|