场景相机初步,日志输出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

@@ -1,7 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame;
using TMPro;
using UniRx;
using UnityEngine;
namespace Ichni.Editor
@@ -14,5 +16,10 @@ namespace Ichni.Editor
{
text.text = content;
}
public void SetUpdatingContent(Func<string> content)
{
Observable.EveryUpdate().Subscribe(_ => text.text = content()).AddTo(gameObject);
}
}
}

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using Ichni.RhythmGame;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
namespace Ichni.Editor
{
@@ -36,5 +37,10 @@ namespace Ichni.Editor
}
connectedBaseElement.Refresh();
}
public void AddListenerFunction(UnityAction<string> action)
{
inputField.onEndEdit.AddListener(action);
}
}
}

View File

@@ -14,7 +14,6 @@ namespace Ichni.Editor
public GameElement connectedGameElement;
public HierarchyTab parentTab;
public List<HierarchyTab> childTabList;
public List<int> IDqueue;
public int tabLayer;
public bool isSelected;
@@ -30,7 +29,6 @@ namespace Ichni.Editor
public void SetTab(GameElement targetElement, GameElement parentElement)
{
connectedGameElement = targetElement;
tabButtonText.text = targetElement.elementName;
targetElement.connectedTab = this;
@@ -49,12 +47,8 @@ namespace Ichni.Editor
this.parentTab = parentElement.connectedTab;
parentElement.connectedTab.childTabList.Add(this);
this.tabLayer = this.parentTab.tabLayer + 1;
this.transform.SetSiblingIndex(this.parentTab.transform.GetSiblingIndex() +
this.parentTab.connectedGameElement.childElementList.Count);
this.transform.SetSiblingIndex(this.parentTab.transform.GetSiblingIndex() + GetAllChildrenCount(this.parentTab));
if (!this.parentTab.isExpanded)
{
this.isExpanded = false;
@@ -63,7 +57,7 @@ namespace Ichni.Editor
for (int i = 1; i <= this.tabLayer; i++)
{
float lineX = 30 * i;
float lineX = 30 * i - 10;
Instantiate(indentationLinePrefab, tabRect).GetComponent<RectTransform>().anchoredPosition = new Vector2(lineX, 0);
}
}
@@ -71,7 +65,6 @@ namespace Ichni.Editor
float posX = -25 +( 30 * tabLayer);
tabMainRect.anchoredPosition = new Vector2(posX, tabMainRect.anchoredPosition.y);
tabButton.onClick.AddListener(SelectGameElement);
expandButton.onClick.AddListener(ExpandOrFold);
}
@@ -104,10 +97,11 @@ namespace Ichni.Editor
if (isExpanded)
{
expandButton.transform.Rotate(new Vector3(0, 0, 180));
foreach (GameElement i in connectedGameElement.childElementList)
for (var index = 0; index < connectedGameElement.childElementList.Count; index++)
{
HierarchyTab a = EditorManager.instance.uiManager.hierarchy.GenerateTab(i, connectedGameElement);
childTabList.Add(a);
var childElement = connectedGameElement.childElementList[index];
EditorManager.instance.uiManager.hierarchy.GenerateTab(childElement, connectedGameElement);
}
}
else

View File

@@ -101,7 +101,7 @@ namespace Ichni.Editor
string title, string parameterName)
{
DynamicUIVector3InputField vector3InputField =
Instantiate(EditorManager.instance.basePrefabs.Vector3inputField, container.rect)
Instantiate(EditorManager.instance.basePrefabs.vector3InputField, container.rect)
.GetComponent<DynamicUIVector3InputField>();
vector3InputField.Initialize(baseElement, title, parameterName);
container.dynamicUIElements.Add(vector3InputField);
@@ -128,20 +128,30 @@ namespace Ichni.Editor
return colorPicker;
}
public DynamicUIHintText GenerateText(IBaseElement baseElement, DynamicUIContainer container, string content)
public DynamicUIHintText GenerateHintText(IBaseElement baseElement, DynamicUIContainer container, string content)
{
DynamicUIHintText parameterText = Instantiate(EditorManager.instance.basePrefabs.text, container.rect)
DynamicUIHintText hintText = Instantiate(EditorManager.instance.basePrefabs.hintText, container.rect)
.GetComponent<DynamicUIHintText>();
parameterText.Initialize(baseElement, string.Empty, string.Empty);
parameterText.SetContent(content);
container.dynamicUIElements.Add(parameterText);
return parameterText;
hintText.Initialize(baseElement, string.Empty, string.Empty);
hintText.SetContent(content);
container.dynamicUIElements.Add(hintText);
return hintText;
}
public DynamicUIHintText GenerateHintText(IBaseElement baseElement, DynamicUIContainer container, Func<string> action)
{
DynamicUIHintText hintText = Instantiate(EditorManager.instance.basePrefabs.hintText, container.rect)
.GetComponent<DynamicUIHintText>();
hintText.Initialize(baseElement, string.Empty, string.Empty);
hintText.SetUpdatingContent(action);
container.dynamicUIElements.Add(hintText);
return hintText;
}
public DynamicUIParameterText GenerateText(IBaseElement baseElement, DynamicUIContainer container, string title,
public DynamicUIParameterText GenerateParameterText(IBaseElement baseElement, DynamicUIContainer container, string title,
string parameterName, bool isAlwaysUpdate = false)
{
DynamicUIParameterText parameterText = Instantiate(EditorManager.instance.basePrefabs.text, container.rect)
DynamicUIParameterText parameterText = Instantiate(EditorManager.instance.basePrefabs.parameterText, container.rect)
.GetComponent<DynamicUIParameterText>();
parameterText.Initialize(baseElement, title, parameterName);
parameterText.isAlwaysUpdated = isAlwaysUpdate;

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d563adb990452433e8dd44155e6e4d33
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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:

View File

@@ -9,5 +9,6 @@ namespace Ichni.Editor
public Canvas mainCanvas;
public ToolBar toolBar;
public ResolutionHints resolutionHints;
public LogWindow logWindow;
}
}