偷看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);
}
}
}