Aetheria/Assets/Scripts/EventLog.cs
Nibu c131045e7d Mining 6 C5: Event Log shows each take (CargoGained), Sell Ore foldout entry; dormant log activated, placeholder text removed
Option event-log of question mining-6-feedback-surface (recommended; no ruling).
Unity files are not compiled here.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 05:32:18 +00:00

36 lines
959 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using TMPro;
using UnityEngine;
public class EventLog : MonoBehaviour
{
public TextMeshProUGUI Log;
public int LineCount = 16;
private SizedQueue<string> LogMessages;
private StringBuilder LogText;
// Awake, not Start: a message can arrive in the frame the parent activates, before Start would run.
private void Awake()
{
LogMessages = new SizedQueue<string>(LineCount);
LogText = new StringBuilder();
Log.text = LogText.ToString();
}
public void LogMessage(string text)
{
LogMessage(text, Color.white);
}
public void LogMessage(string text, Color color)
{
LogMessages.Enqueue($"<color=#{ColorUtility.ToHtmlStringRGB(color)}>{text}");
LogText.Clear();
foreach (var s in LogMessages) LogText.AppendLine(s);
Log.text = LogText.ToString();
}
}