using System; using System.Collections; using System.Collections.Generic; using Lean.Pool; using UnityEngine; namespace Ichni.Editor { public class LogWindow : MonoBehaviour { public GameObject logTextPrefab; public RectTransform textRect; public Queue logTexts; public int logTextCapacity = 4; private void Start() { logTexts = new Queue(); } public void AddLog(string text, Color color = default) { CheckLogTextCapacity(); LogText logText = LeanPool.Spawn(logTextPrefab, textRect).GetComponent(); if (color == default) color = Color.white; logText.SetLogText(text, color); logTexts.Enqueue(logText); } private void CheckLogTextCapacity() { if (logTexts.Count >= logTextCapacity) { LeanPool.Despawn(logTexts.Dequeue().gameObject); } } } }