I’m writing an addon that will read from a file and add nodes to a Geometry Script Blueprint.
What is the command, with exact syntax for both .h and .cpp, #include files, and modules needed?
I’ve been digging for hours and can’t seem to find anything to use.
P.S. I’m not good at coding… which is why I use Geometry scripting & Geometry nodes in the first place.
But “setFromFunction” requires a “UFUNCTION” variable, and I have no idea the syntax to pass that through.
Say, for example the Ufunction I want to spawn is “static UBlueprint* CreateBlueprint”, what’s the syntax? I’ve tried just the function name, with quotes, with &&, etc.
by node, are you looking for adding a new function into blueprint? because in that case, id recommend you create a plugin with the type of blueprint function library. its a pretty simple setup operation, and unreal handles most of the stuff for you.
id also recommend taking a look at other peoples plugins (or the engine code) to see what they are doing. a simple plugin with one .h and one .cpp file would probably be a ideal to work with.
There are no addons that add nodes to blueprints, that I can find.
“its a pretty simple setup operation” -_- If it were simple I’d have it done already. I’m on hour #38 trying to simply add a node to an event graph. Frustration abounds.
Clarification: Not trying to make a function “blueprint callable”, I’m trying to add a callable function node to a graph.
i wasnt sure what you were wanting specifically because of the way you worded it, so thats why i didnt provide any example code; it would be quite a a waste of work to creat some code that you arnt going to use (case in point this exact situation). you already know how to make a function blueprint callable it seems, so my provided code would be useless for your situation.
as for your specific question, im not totally sure how to help unfortunately, now that i better understand it
Well, thanks for taking the time. I’ve already logged 48+ hours for bashing my face into a wall just to add a node to a graph. I think it’s time to hope on fivr, and see if I can get someone to help.
You know how you Right click on a graph, and select a node, and that node is added to the graph?
I’m trying to call the function that adds the selected “function node” to the graph.
The two parts of the syntax I don’t understand:
the “UFunction” variable, how do I set it to the function I want, like “Add Triangle to Mesh”?
And “Bindings” variable, I can’t figure out what I’m supposed to pass (and how)
UEdGraphNode* UMakeBlueprintNodeBPLibrary::AddNodeToBlueprint3(UBlueprint* Blueprint, FName FunctionName, UClass* Class, FVector Location)
{
if (!Blueprint)
{
// Blueprint is null, handle the error
return nullptr;
}
if (!Class)
{
// The blueprint class is null, handle the error
return nullptr;
}
UFunction* Function = Class->FindFunctionByName(FunctionName);
if (!Function)
{
// The function does not exist in the blueprint class, handle the error
UE_LOG(LogTemp, Warning, TEXT("Function Not Found"));
return nullptr;
}
// Get the Event Graph of the blueprint
UEdGraph* EventGraph = Blueprint->UbergraphPages[0];
// Create a new function node in the Event Graph
UEdGraphNode* NewNode = NewObject<UEdGraphNode>(EventGraph);
UBlueprintFunctionNodeSpawner* FunctionNodeSpawner = UBlueprintFunctionNodeSpawner::Create(Function);
if (FunctionNodeSpawner)
{
FunctionNodeSpawner->SetFlags(RF_Transactional);
NewNode = FunctionNodeSpawner->Invoke(EventGraph, IBlueprintNodeBinder::FBindingSet(), FVector2D(Location.X, Location.Y));
return NewNode;
}
return nullptr;