场景相机初步,日志输出LogWindow

This commit is contained in:
SoulliesOfficial
2025-02-18 10:30:11 -05:00
parent 8d4772532f
commit b36f0469d0
31 changed files with 1497 additions and 721 deletions

View File

@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using Lean.Pool;
using TMPro;
using UnityEngine;
namespace Ichni.Editor
{
public class LogText : MonoBehaviour
{
public TMP_Text logText;
public void SetLogText(string text, Color color)
{
logText.text = text;
logText.color = color;
string logFilePath = EditorManager.instance.projectInformation.projectPath + "/Logs/EditorLog.txt";
// if(!ES3.FileExists(logFilePath)) System.IO.File.Create(logFilePath).Dispose();
//
// System.IO.File.AppendAllText(logFilePath, text + "\n");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c627b09eb0f984c59b55367c47919d38
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d537bd381617a4941839f44c04840c28
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: