First and foremost, my goal is not to show a custom node for a function. My goal is to create an entirely custom blueprint node that I can use in the blueprint graph editor like suggested in this tutorial. I am doing this by trying to create a non relevant test node:
https://wiki.unrealengine.com/Create_Custom_K2_Node_For_Blueprint
That being said, I’m having trouble following it. I created an Editor Module following this tutorial:
https://answers.unrealengine.com/questions/41509/extending-editor-engine.html
The module is visible and I can add code to it using the “new c++ class” function provided in the editor and selecting my module in the dropdown. I interpret from this that it was created successfully.
I’ve added a BlueprintFunctionLibrary to the runtime module as instructed in the tutorial, and I added a function for testing purposes (please, don’t mind the names):
InputGraph_BlueprintNodes.h
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "InputGraph_BlueprintNodes.generated.h"
UCLASS()
class RTSCAMERATEST_API UInputGraph_BlueprintNodes : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", FriendlyName = "Input System Test Node", BlueprintInternalUseOnly = "true"), Category = "Custom UK2Node Input Module")
static bool CheckMyDubs(int32 n);
};
The function itself is not relevant, it will just return a boolean based on a simple non relevant condition.
Then I added the dependencies as stated by the tutorial and proceeded to try to understand how the node itself was implemented. I added the K2Node derivate class to the Editor Module as instructed. Here is where I crashed and burned.
https://docs.unrealengine.com/latest/INT/API/Editor/BlueprintGraph/UK2Node/index.html
I used the source code in github for the K2Node class and several of its derivates as well as the c++ reference of the K2Node class (see the link above) to understand how does this work. However, after banging my head for several days without results, here are the questions I have not been able to resolve with the available information I found:
1 - K2Node Class Derivate: Which functions do I need to implement there so that a basic custom hello world style node shows up and works?
The K2Node class has several functions. Of all of those, which ones are the minimum necessary to implement so that the node shows up in a blueprint editor graph? Think a minimum hello world test node.
Remember as well, I’m trying to create a custom blueprint node derivating from K2Node to use it in the blueprint graph editor, not just exposing a function as a custom blueprint node.
2 - What is the exact purpose of the K2Node Expand Node method?
In the API reference, there is no description for this method. In the tutorial I am following, the provided explanation does not suffice to me: the provided comment states that it will “expand node for our custom object”. I can’t understand what this means, as it does not provide details about what “expanding a node” actually means. I try to read the code but I can’t seem to catch the inner workings of it. It looks as if it uses this class (UWidgetBlueprintLibrary) to deal with the UI side of things.
Several things I don’t quite understand here:
a) In the comments of the cpp, it speaks about creating connections and moving pins. Is it referring to the execution flow or the graphical pins and s-curved lines we see in the graph editor?
b) Is “world context object” something relevant to me or just his particular node in the tutorial?
c) It seems as if Expand Node is the function that actually makes the node visible and creates its UI, however, there are several instances of nodes in the source code of the engine, like the If Then Else node or the Switch node that do not implement this method.
If it is, why isn’t it implemented in these nodes? If it’s not, then what does make the node visible? Is it the Compile method implemented in nodes like the If Then Else node? Why do the nodes that implement Compile inherit from a different parent class than the nodes which implement Expand Node? Are Flow Control nodes different from the rest in this regard? And if so, why?
Finally, I give thanks in advance to anybody who tries to help me with this subject, as it seems like information about this particular topic of creating custom blueprints through inheritance is pretty scarce. Either that or I don’t know how to search for it. Any kind of help will be welcome.