场景相机初步,日志输出LogWindow
This commit is contained in:
39
Assets/Scripts/DynamicUI/MainUI/LogWindow/LogWindow.cs
Normal file
39
Assets/Scripts/DynamicUI/MainUI/LogWindow/LogWindow.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
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<LogText> logTexts;
|
||||
public int logTextCapacity = 4;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
logTexts = new Queue<LogText>();
|
||||
}
|
||||
|
||||
public void AddLog(string text, Color color = default)
|
||||
{
|
||||
CheckLogTextCapacity();
|
||||
LogText logText = LeanPool.Spawn(logTextPrefab, textRect).GetComponent<LogText>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user