偷看Hierarchy

试图做一点优化但是失败了(
在下面控制台输loopg("track名字",int)可以在某个track下生成一大堆pathnode来测试Hierarchy的性能
目前超过5000就卡了
This commit is contained in:
2025-02-10 15:56:10 +08:00
parent d3928be99f
commit 30653e133b
8 changed files with 426 additions and 371 deletions

View File

@@ -4,12 +4,15 @@ using System.Collections.Generic;
using UnityEngine;
using DynamicExpresso;
using UnityEngine.UI;
using UnityEngine.Events;
using Dreamteck;
using System.Text.RegularExpressions;
using DynamicExpresso.Exceptions;
using UnityEngine.UIElements;
using System.Linq;
using Unity.VisualScripting;
using Ichni.RhythmGame;
using Sirenix.Utilities;
//又在写大粪 ——神币
namespace Ichni.Editor
{
@@ -25,26 +28,32 @@ namespace Ichni.Editor
public void GetChange(string change){
//print(change[InputCommand.caretPosition-1]);
}
public void GetCommand(string Command)//当提交命令时
{
if(InputCommand.text=="")return;
try{functionInterpreter.Eval(Command);
}catch(UnknownIdentifierException){Debug.LogWarning("指令未找到!");}
if(historyCommand.ContainsKey(historycount))historyCommand[historycount]=Command;
else historyCommand.Add(historycount,Command);
historycount++;
InputCommand.text="";
try{functionInterpreter.Eval(Command);
}catch(Exception e){Debug.LogWarning("WTF Command! "+e);}
}
private void Update(){
if(InputCommand.isFocused){
if(Input.GetKeyDown(KeyCode.DownArrow)&&historyCommand.Count-1>historycount){
historycount++;
InputCommand.text=historyCommand[historycount];
}else if(Input.GetKeyDown(KeyCode.UpArrow)&&historycount!=0){
if(Input.GetKeyDown(KeyCode.DownArrow)){
if(historyCommand.Count-1>historycount){
historycount++;
InputCommand.text=historyCommand[historycount];}
else {
InputCommand.text="";
historycount=historyCommand.Count;
}
}
if(Input.GetKeyDown(KeyCode.UpArrow)&&historycount!=0){
historycount--;
InputCommand.text=historyCommand[historycount];
}
@@ -68,38 +77,65 @@ namespace Ichni.Editor
public partial class EditorConsole
{
private delegate int math(int A);
private delegate void Batch(GameObject[] objet,string prop,int loop,string expression);
private delegate void Batch(string name,string prop,int loop,string expression);
private Batch _batch;
private math _math;
private void SetUpFunctions()
{
functionInterpreter = new Interpreter();
functionInterpreter.SetFunction("loopg", (Action<string,int>)LoopGenerate);
functionInterpreter.SetFunction("print", (Action<object>)print);
functionInterpreter.SetFunction("log", (Action<object>)Debug.Log);
_batch=BatchGenerate;
functionInterpreter.SetFunction("BatchGenerate",_batch);
_math=swap;
functionInterpreter.SetFunction("swap",_math);
_math=zheng;
functionInterpreter.SetFunction("nswap",_math);
}
private int zheng(int A){
print(A);
return A;}
private int swap(int A){
print(-A);
return -A;}
private void BatchGenerate(GameObject[] objet,string prop,int loop,string expression){//
private GameElement Find(object name){
string text=name.ToString();
GameElement[] allObjects = Resources.FindObjectsOfTypeAll(typeof(GameElement)) as GameElement[];
List<int> objs = new List< int > ();
List<GameElement> obji = new List< GameElement > ();
foreach (GameElement obj in allObjects){
if (obj.elementName == text) {
objs.Add(obj.GetInstanceID());
obji.Add(obj);
print(objs[objs.Count()-1]);
}
}
//TODO duotrack选择菜单
if(obji.IsNullOrEmpty()){
Debug.LogWarning("no find");
return null;}
return obji[0];
}
private void BatchGenerate(string name,string prop,int loop,string expression){//
GameElement[] allObjects = Resources.FindObjectsOfTypeAll(typeof(GameElement)) as GameElement[];
List<int> objs=new();
foreach (GameElement obj in allObjects){
if(obj.elementName==name)objs.Add(obj.GetInstanceID());
}
print(objs);
//TODO: 预制件,属性,循环数,表达式
print("在做了");
}
private void BatchSet(GameObject[] objet,string prop,int loop,string expression){//
//TODO: 预制件,属性,循环数,表达式
print("在做了");
private void LoopGenerate(string name,int time){
Track track= (Track)Find(name);
for(int i=0;i<time;i++){
PathNode.GenerateElement("PathNodes", Guid.NewGuid(), new List<string>(), true,track);
}
}
}

View File

@@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame;
using UnityEngine;
using UnityEngine.UI;
namespace Ichni.Editor
{
@@ -9,14 +10,17 @@ namespace Ichni.Editor
{
public GameObject hierarchyTabPrefab;
public RectTransform tabContainer;
public List<HierarchyTab> tabList;
public void GenerateTab(GameElement targetElement, GameElement parentElement)
{
HierarchyTab tab = Instantiate(hierarchyTabPrefab, tabContainer).GetComponent<HierarchyTab>();
tab.SetTab(targetElement, parentElement);
tabList.Add(tab);
}
}
}

View File

@@ -46,7 +46,7 @@ CanvasRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1975073476707558943}
m_CullTransparentMesh: 1
m_CullTransparentMesh: 0
--- !u!114 &8976681661139621974
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -61,7 +61,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
@@ -104,7 +104,7 @@ MonoBehaviour:
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_FadeDuration: 0
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
@@ -203,7 +203,7 @@ CanvasRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3176678068745517715}
m_CullTransparentMesh: 1
m_CullTransparentMesh: 0
--- !u!114 &2880005684537739809
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -414,7 +414,7 @@ CanvasRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3806841418187787967}
m_CullTransparentMesh: 1
m_CullTransparentMesh: 0
--- !u!114 &1918472174654462383
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -429,7 +429,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
@@ -472,7 +472,7 @@ MonoBehaviour:
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_FadeDuration: 0
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
@@ -533,7 +533,7 @@ CanvasRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4380206872013282838}
m_CullTransparentMesh: 1
m_CullTransparentMesh: 0
--- !u!114 &4291529747774764318
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -667,7 +667,7 @@ CanvasRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5555805119357131721}
m_CullTransparentMesh: 1
m_CullTransparentMesh: 0
--- !u!114 &7050386563054743178
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -889,7 +889,7 @@ CanvasRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7511642132255200178}
m_CullTransparentMesh: 1
m_CullTransparentMesh: 0
--- !u!114 &897315520404165281
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -904,7 +904,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
@@ -947,7 +947,7 @@ MonoBehaviour:
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_FadeDuration: 0
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}