2026-03-13 05:34:19 -04:00
|
|
|
#include "MCPNotifier.h"
|
|
|
|
|
#include "EdGraph/EdGraphNode.h"
|
|
|
|
|
#include "EdGraph/EdGraph.h"
|
|
|
|
|
#include "Engine/Blueprint.h"
|
|
|
|
|
#include "Materials/Material.h"
|
|
|
|
|
#include "Kismet2/BlueprintEditorUtils.h"
|
|
|
|
|
#include "MaterialEditingLibrary.h"
|
|
|
|
|
|
2026-03-13 13:46:12 -04:00
|
|
|
void MCPNotifier::AddTouchedObject(UObject* Obj)
|
2026-03-13 05:34:19 -04:00
|
|
|
{
|
|
|
|
|
if (!Obj) return;
|
|
|
|
|
bool bAlreadyInSet = false;
|
|
|
|
|
TouchedSet.Add(Obj, &bAlreadyInSet);
|
|
|
|
|
if (bAlreadyInSet) return;
|
|
|
|
|
TouchedArray.Add(Obj);
|
2026-03-13 13:46:12 -04:00
|
|
|
Obj->PreEditChange(nullptr);
|
2026-03-13 05:34:19 -04:00
|
|
|
}
|
|
|
|
|
|
2026-03-13 13:46:12 -04:00
|
|
|
void MCPNotifier::SendNotifications()
|
2026-03-13 05:34:19 -04:00
|
|
|
{
|
|
|
|
|
TSet<UEdGraphNode*> Nodes;
|
|
|
|
|
TSet<UEdGraph*> Graphs;
|
|
|
|
|
TSet<UMaterial*> Materials;
|
|
|
|
|
TSet<UBlueprint*> Blueprints;
|
|
|
|
|
for (int32 i = TouchedArray.Num() - 1; i >= 0; --i)
|
|
|
|
|
{
|
|
|
|
|
UObject* Obj = TouchedArray[i];
|
|
|
|
|
Obj->PostEditChange();
|
|
|
|
|
Obj->MarkPackageDirty();
|
|
|
|
|
|
|
|
|
|
if (UEdGraphNode* Node = ::Cast<UEdGraphNode>(Obj))
|
|
|
|
|
Nodes.Add(Node);
|
|
|
|
|
|
|
|
|
|
if (UEdGraph* Graph = ::Cast<UEdGraph>(Obj))
|
|
|
|
|
Graphs.Add(Graph);
|
|
|
|
|
|
|
|
|
|
if (UBlueprint* BP = ::Cast<UBlueprint>(Obj))
|
|
|
|
|
Blueprints.Add(BP);
|
|
|
|
|
|
|
|
|
|
if (UMaterialInterface* MatIface = ::Cast<UMaterialInterface>(Obj))
|
|
|
|
|
if (UMaterial* BaseMat = MatIface->GetMaterial())
|
|
|
|
|
Materials.Add(BaseMat);
|
|
|
|
|
}
|
|
|
|
|
for (UEdGraphNode* Node : Nodes)
|
|
|
|
|
Node->ReconstructNode();
|
|
|
|
|
for (UEdGraph* Graph : Graphs)
|
|
|
|
|
Graph->NotifyGraphChanged();
|
|
|
|
|
for (UMaterial *Material : Materials)
|
|
|
|
|
UMaterialEditingLibrary::RebuildMaterialInstanceEditors(Material);
|
|
|
|
|
for (UBlueprint *Blueprint : Blueprints)
|
|
|
|
|
FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(Blueprint);
|
|
|
|
|
|
|
|
|
|
if (GEditor)
|
|
|
|
|
GEditor->RedrawAllViewports();
|
|
|
|
|
|
2026-03-13 13:46:12 -04:00
|
|
|
TouchedSet.Empty();
|
|
|
|
|
TouchedArray.Empty();
|
2026-03-13 05:34:19 -04:00
|
|
|
}
|