perf
This commit is contained in:
@@ -3,10 +3,11 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public abstract partial class GameElement : SerializedMonoBehaviour, IBaseElement, IComparable<GameElement>
|
||||
public abstract partial class GameElement : MonoBehaviour, IBaseElement, IComparable<GameElement>
|
||||
{
|
||||
//物体名
|
||||
public string elementName;
|
||||
@@ -50,7 +51,6 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
|
||||
SetParent(parentElement);
|
||||
// EditorManager.instance.uiManager.hierarchy.GenerateTab(this, parentElement);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -60,18 +60,23 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void SetEditorSubmodules()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 在所有物体生成完毕后,执行的初始化方法
|
||||
/// </summary>
|
||||
public virtual void AfterInitialize()
|
||||
{
|
||||
SetEditorSubmodules();
|
||||
matchedBM?.AfterExecute();
|
||||
|
||||
if (this is IHaveTransformSubmodule transformSource)
|
||||
{
|
||||
transformSource.transformSubmodule.CheckAndRemoveObservers();
|
||||
}
|
||||
|
||||
if(this is IHaveColorSubmodule colorSource)
|
||||
{
|
||||
colorSource.colorSubmodule.CheckAndRemoveObservers();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -117,55 +122,6 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除物体,包括所有子物体
|
||||
/// </summary>
|
||||
public virtual void Delete()
|
||||
{
|
||||
if (childElementList is { Count: > 0 })
|
||||
{
|
||||
for (int i = 0; i < childElementList.Count; i++)
|
||||
{
|
||||
childElementList[i].Delete(); //删除子GameElement、
|
||||
}
|
||||
}
|
||||
|
||||
OnDelete();
|
||||
|
||||
//LogWindow.Log("Deleted element: " + elementName);
|
||||
|
||||
//EditorManager.instance.beatmapContainer.gameElementList.Remove(this); //从保存列表中剔除
|
||||
|
||||
Destroy(gameObject); //销毁
|
||||
}
|
||||
}
|
||||
|
||||
public abstract partial class GameElement
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取所有子GameElement
|
||||
/// </summary>
|
||||
/// <param name="includeThis">是否包括自身</param>
|
||||
public List<GameElement> GetAllGameElementsFromThis(bool includeThis = true)
|
||||
{
|
||||
void GetAllChildrenRecursively(GameElement parent, List<GameElement> elements)
|
||||
{
|
||||
foreach (var child in parent.childElementList)
|
||||
{
|
||||
elements.Add(child);
|
||||
GetAllChildrenRecursively(child, elements);
|
||||
}
|
||||
}
|
||||
|
||||
List<GameElement> gameElements = new List<GameElement> { this };
|
||||
GetAllChildrenRecursively(this, gameElements);
|
||||
|
||||
if (!includeThis) gameElements.Remove(this);
|
||||
|
||||
return gameElements;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
|
||||
Reference in New Issue
Block a user