Hi, I’m trying to build blueprint graphs through C++ and I encountered a problem when trying to create a Flip Flop node.
The node, alongside many others, is a macro node, which means it is a “shortcut” to a subgraph that handles the logic (in this case alternating between A and B).
Here is the code for my attempt (does not work):
CreateFlipFlopNode(UEdGraph* EventGraph, FVector2D Position) {
// Create the Flip Flop node
UBlueprintNodeSpawner* NodeSpawner = UBlueprintNodeSpawner::Create(UK2Node_MacroInstance::StaticClass());
UEdGraphNode* Node = NodeSpawner->Invoke(EventGraph, IBlueprintNodeBinder::FBindingSet(), Position);
// Set up the node parameters
UK2Node_MacroInstance* FlipFlopNode = Cast<UK2Node_MacroInstance>(Node);
if (FlipFlopNode) {
// TODO: Find a way to set the macro graph to flip flop's
// UObject* Obj = StaticLoadObject(UEdGraph::StaticClass(), nullptr, *FString("/Script/Engine.EdGraph'/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:FlipFlop'"));
UEdGraph* Graph = Cast<UEdGraph>(Obj);
if (Graph) {
FlipFlopNode->SetMacroGraph(Graph);
}
}
return Node;
}
Essentially, I need to find a way to get the node’s macro graph. From what I can see when copy-pasting the node into a notepad, it should be located at "/Script/Engine.EdGraph'/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:FlipFlop'"
.
Does anyone know how I can find and retrieve the graph to spawn the correct node?
Thanks