I’m trying to copy a macro from one blueprint to another using C++. (The new blueprint is made using C++, which is why it can’t be added the normal way)
I’ve tried:
// Get the function graph from the source Blueprint
UEdGraph* SourceGraph = SourceBlueprint->FunctionGraphs[Graph];
// Duplicate the function graph
UEdGraph* DuplicatedGraph = FEdGraphUtilities::CloneGraph(SourceGraph, TargetBlueprint);
// Add the duplicated function graph to the target Blueprint
TargetBlueprint->FunctionGraphs.Add(DuplicatedGraph);
But this yields an unnamed Function Graph instead of a Named Macro
Also tried:
FBlueprintEditorUtils::AddMacroGraph(TargetBlueprint, SourceGraph, true, nullptr);
But this links the macro to the original file, making the new file unsavable.
I can’t use a blueprint library, as the macro needs to change global variables.
I can’t use a function, because the input needs to changed based on what happens internally.
Example: Set position macro with an input of “MPosition” and Mesh. Internally it gets a position from the mesh, and iterates over all the points and sets the position to MPosition.
Outside the macro, is a global Variable “GPosition”. Inside the macro, it sets GPosition to the original position of point being iterated.
Basically: I’m trying to create a macro or function that works like “Set Position” of Blender’s Geometry nodes.
The function Doesn’t work because it just gets the value “GPosition” is static.
The macro works, but I can’t seem to copy it to a new blueprint correctly.
Thanks for any help.