优化hierarchyab和consolemethod,然后是粒子追踪
Signed-off-by: TRADER_FOER <lhf190@outlook.com>
This commit is contained in:
@@ -48,21 +48,14 @@ namespace Ichni.Editor
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重命名选中元素
|
||||
/// </summary>
|
||||
public static void ReName(string message)
|
||||
{
|
||||
inspector.connectedGameElement.elementName = message;
|
||||
inspector.connectedGameElement.Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PathNode Generation (路径节点生成)
|
||||
/// <summary>
|
||||
/// 直线路径节点生成 (Line PathNode Generator)
|
||||
/// </summary>
|
||||
public static void Lgp(int loop, Vector3 start, Vector3 end, bool Clear = false, bool offsetOrigin = false)
|
||||
public static void Lgp(int loop, Vector3 start, Vector3 end, bool Clear = false)
|
||||
{
|
||||
if (inspector.connectedGameElement == null || inspector.connectedGameElement.GetType() != typeof(Track))
|
||||
{
|
||||
@@ -80,17 +73,10 @@ namespace Ichni.Editor
|
||||
// 如果 Clear 且有旧节点,迁移变换
|
||||
|
||||
if (Clear)
|
||||
{
|
||||
if (offsetOrigin && oldNodes.Count > 0 && newNodes.Count > 0)
|
||||
{
|
||||
AdjustPathNodesToNearest(track, newNodes, oldNodes);
|
||||
}
|
||||
// 清除之前的PathNode
|
||||
foreach (var node in oldNodes)
|
||||
{
|
||||
EditorManager.instance.operationManager.CopyPasteDeleteModule.DeleteElement(node);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < loop; i++)
|
||||
{
|
||||
float t = (float)i / (loop - 1); // 修正插值
|
||||
@@ -186,33 +172,7 @@ namespace Ichni.Editor
|
||||
|
||||
#region PathNode/Track Utilities (路径节点/轨道工具)
|
||||
|
||||
/// <summary>
|
||||
/// 将原有 PathNode 的变换(位置、旋转、缩放)迁移到新生成的最近 PathNode 上
|
||||
/// </summary>
|
||||
public static bool AdjustPathNodesToNearest(Track track, List<PathNode> newNodes, List<PathNode> oldNodes)
|
||||
{
|
||||
foreach (var oldNode in oldNodes)
|
||||
{
|
||||
// 找到距离 oldNode 最近的新节点
|
||||
PathNode nearest = newNodes
|
||||
.OrderBy(n => Vector3.Distance(n.transformSubmodule.originalPosition, oldNode.transformSubmodule.originalPosition))
|
||||
.FirstOrDefault();
|
||||
|
||||
if (nearest != null)
|
||||
{
|
||||
// 计算 oldNode 的变换(直接用欧拉角,不用四元数)
|
||||
Vector3 deltaPos = oldNode.transformSubmodule.originalPosition - oldNode.transformSubmodule.originalPosition;
|
||||
Vector3 deltaEuler = oldNode.transformSubmodule.originalEulerAngles - oldNode.transformSubmodule.originalEulerAngles;
|
||||
Vector3 deltaScale = oldNode.transformSubmodule.originalScale - oldNode.transformSubmodule.originalScale;
|
||||
|
||||
// 将变换应用到新节点
|
||||
nearest.transformSubmodule.originalPosition += deltaPos;
|
||||
nearest.transformSubmodule.originalEulerAngles += deltaEuler;
|
||||
nearest.transformSubmodule.originalScale += deltaScale;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除父元素下所有与当前选中元素类型相同的其他元素,最后删除当前选中元素
|
||||
|
||||
Reference in New Issue
Block a user