More work on graph editing

This commit is contained in:
2026-03-13 00:48:19 -04:00
parent 8715cd25b0
commit 7202ef9bf6
8 changed files with 223 additions and 120 deletions

View File

@@ -6,6 +6,9 @@
#include "MCPUtils.h"
#include "EdGraph/EdGraph.h"
#include "EdGraph/EdGraphNode.h"
#include "MaterialGraph/MaterialGraphNode.h"
#include "Materials/Material.h"
#include "IMaterialEditor.h"
#include "GraphNode_Delete.generated.h"
@@ -47,8 +50,21 @@ public:
}
F.PreEdit();
FoundNode->BreakAllNodeLinks();
Graph->RemoveNode(FoundNode);
if (Cast<UMaterialGraphNode>(FoundNode))
{
// Use the material editor's DeleteNodes to properly remove
// both the graph node and the underlying material expression.
IMaterialEditor* MatEditor = F.CastEditor<UMaterial, IMaterialEditor>();
if (!MatEditor) return;
MatEditor->DeleteNodes({FoundNode});
}
else
{
FoundNode->BreakAllNodeLinks();
Graph->RemoveNode(FoundNode);
}
F.PostEdit();
Result.Appendf(TEXT("Deleted node '%s' from graph '%s'.\n"), *NodeTitle, *GraphName);