场景相机初步,日志输出LogWindow
This commit is contained in:
8
Assets/Scripts/DynamicUI/MainUI/LogWindow.meta
Normal file
8
Assets/Scripts/DynamicUI/MainUI/LogWindow.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d563adb990452433e8dd44155e6e4d33
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/Scripts/DynamicUI/MainUI/LogWindow/LogText.cs
Normal file
25
Assets/Scripts/DynamicUI/MainUI/LogWindow/LogText.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/DynamicUI/MainUI/LogWindow/LogText.cs.meta
Normal file
11
Assets/Scripts/DynamicUI/MainUI/LogWindow/LogText.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c627b09eb0f984c59b55367c47919d38
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/DynamicUI/MainUI/LogWindow/LogWindow.cs.meta
Normal file
11
Assets/Scripts/DynamicUI/MainUI/LogWindow/LogWindow.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d537bd381617a4941839f44c04840c28
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -9,5 +9,6 @@ namespace Ichni.Editor
|
||||
public Canvas mainCanvas;
|
||||
public ToolBar toolBar;
|
||||
public ResolutionHints resolutionHints;
|
||||
public LogWindow logWindow;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user