@@ -1,8 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ichni.Editor.Commands;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
@@ -126,9 +127,9 @@ namespace Ichni.Editor
|
||||
copiedElement = gameElement;
|
||||
}
|
||||
|
||||
public void PasteElement(GameElement parentElement)
|
||||
{
|
||||
if (parentElement == null)
|
||||
public void PasteElement(GameElement parentElement)
|
||||
{
|
||||
if (parentElement == null)
|
||||
{
|
||||
LogWindow.Log("No parent element selected to paste.", Color.red);
|
||||
return;
|
||||
@@ -137,44 +138,73 @@ namespace Ichni.Editor
|
||||
if (copiedElement == null)
|
||||
{
|
||||
LogWindow.Log("No element copied.");
|
||||
return;
|
||||
}
|
||||
|
||||
LogWindow.Log("Pasted element: " + copiedElement.elementName + " to " + parentElement.elementName);
|
||||
pastedElementList = new List<GameElement>();
|
||||
AffiliatedPaste(copiedElement, parentElement);
|
||||
|
||||
// 粘贴完成后,对所有新生成的元素执行 AfterInitialize 和 Refresh,
|
||||
// 与 EditorManager.LoadProject 的加载后流程对齐,确保 Manager 注册等关键步骤不遗漏。
|
||||
return;
|
||||
}
|
||||
|
||||
CommandManager.ExecuteCommand(new PasteElementCommand(this, copiedElement, parentElement));
|
||||
}
|
||||
|
||||
public GameElement PasteElementRaw(GameElement sourceElement, GameElement parentElement)
|
||||
{
|
||||
if (sourceElement == null || parentElement == null) return null;
|
||||
|
||||
LogWindow.Log("Pasted element: " + sourceElement.elementName + " to " + parentElement.elementName);
|
||||
pastedElementList = new List<GameElement>();
|
||||
AffiliatedPaste(sourceElement, parentElement);
|
||||
|
||||
// 粘贴完成后,对所有新生成的元素执行 AfterInitialize 和 Refresh,
|
||||
// 与 EditorManager.LoadProject 的加载后流程对齐,确保 Manager 注册等关键步骤不遗漏。
|
||||
foreach (GameElement pasted in pastedElementList)
|
||||
{
|
||||
if (pasted == null) continue;
|
||||
pasted.AfterInitialize();
|
||||
pasted.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteElement(GameElement gameElement)
|
||||
pasted.AfterInitialize();
|
||||
pasted.Refresh();
|
||||
}
|
||||
|
||||
return pastedElementList.FirstOrDefault();
|
||||
}
|
||||
|
||||
public void DeleteElement(GameElement gameElement)
|
||||
{
|
||||
if (gameElement == null)
|
||||
{
|
||||
LogWindow.Log("No element selected to delete.", Color.red);
|
||||
return;
|
||||
}
|
||||
|
||||
LogWindow.Log("Deleted element: " + gameElement.elementName + " and all its children.");
|
||||
|
||||
if (gameElement.parentElement != null)
|
||||
{
|
||||
gameElement.parentElement.childElementList.Remove(gameElement); //从父物体的子物体列表中移除,避免报null
|
||||
gameElement.parentElement.connectedTab.childTabList.Remove(gameElement.connectedTab);
|
||||
gameElement.parentElement.connectedTab.SetStatus();
|
||||
}
|
||||
|
||||
EditorManager.instance.operationManager.RemoveSelectElement(gameElement);
|
||||
gameElement.Delete();
|
||||
EditorManager.instance.uiManager.inspector.ClearInspector();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CommandManager.ExecuteCommand(new DeleteElementCommand(gameElement));
|
||||
}
|
||||
|
||||
public void DeleteElementRaw(GameElement gameElement, bool writeLog = true)
|
||||
{
|
||||
if (gameElement == null) return;
|
||||
|
||||
var deletedElements = gameElement.GetAllGameElementsFromThis();
|
||||
var deletedGuids = deletedElements.Select(element => element.elementGuid).ToList();
|
||||
var deletedTabs = deletedElements
|
||||
.Select(element => element.connectedTab)
|
||||
.Where(tab => tab != null)
|
||||
.ToList();
|
||||
|
||||
if (writeLog)
|
||||
LogWindow.Log("Deleted element: " + gameElement.elementName + " and all its children.");
|
||||
|
||||
if (gameElement.parentElement != null)
|
||||
{
|
||||
gameElement.parentElement.childElementList.Remove(gameElement); //从父物体的子物体列表中移除,避免报null
|
||||
if (gameElement.parentElement.connectedTab != null)
|
||||
{
|
||||
gameElement.parentElement.connectedTab.childTabList.Remove(gameElement.connectedTab);
|
||||
gameElement.parentElement.connectedTab.SetStatus();
|
||||
}
|
||||
}
|
||||
|
||||
EditorManager.instance.operationManager.RemoveSelectElement(gameElement);
|
||||
gameElement.Delete();
|
||||
deletedGuids.ForEach(guid => GameElement_BM.identifier.Remove(guid));
|
||||
deletedTabs.ForEach(tab => EditorManager.instance.uiManager.hierarchy.tabList.Remove(tab));
|
||||
EditorManager.instance.uiManager.inspector.ClearInspector();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用递归的方式复制粘贴物体及其所有子物体
|
||||
|
||||
Reference in New Issue
Block a user