Custom Blueprint K2Node Creation: Node doesn't show up

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.

Two weeks ago I opened this thread in the forums with additional information:

https://forums.unrealengine.com/showthread.php?65992-Making-a-Custom-Blueprint-K2Node-in-C-can-anybody-help-me-please

I still need help with this, as I have not been able to pinpoint my mistakes yet. Any help would still be very appreciated.

I just fully confirmed that my Editor Module is working properly. The problem then is the K2Node’s implementation itself! Source. If I manage to fix the implementation, then it’ll be solved.

Solved! My node is finally showing up!

The problem was that in the tutorial I was following, GetMenuEntries is used. However, there is a replacement method for it, GetMenuActions. Both are available in the K2Node API.

You need to override GetNodeTitle and GetMenuActions for your node to register properly into the blueprint system.

I haven’t confirmed this yet, but GetContextMenuActions might be used when you’re creating a compatible node from a pin from another node. If I can confirm this, I’ll update this answer.

You can find more information here.

About the Editor Module, the only naming requisite is the YourProjectNameEditor.target.cs file inside the root source folder of your project. You can name your modules however you want.