Hi! I have a function library that I am updating and using along my projects with very simple but useful functions and I would like to start implementing it as a plugin.
I created a plugin selecting this option:
called the plugin as : BlueprintExtraNodes
then I added a test function in the main.h file BlueprintExtraNodes.h:
#pragma once
#include "Modules/ModuleManager.h"
class FBlueprintExtraNodesModule : public IModuleInterface
{
public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
/* here is my test function */
UFUNCTION(BlueprintCallable)
void SayHi()
{
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::White, FString::Printf(TEXT("Hi!")));
}
};
I compile without errors but even restarting the project, the test function doesn’t appears in the blueprints:
Do not add your functions in the IModuleInterface thing.
Create a new class (UCLASS) that extends UBlueprintFunctionLibrary, and put your utilities there. Also, your functions should be static in order to be useable anywhere. In many cases, you’ll want to pass a WorldContextObject. Refer to builtin KismetSystemLibrary for examples.
In C++ you can’t. In blueprints the parameter is still there, it’s just hidden most of the time as blueprints are context-aware and know when they can use “Self” as world-context object.
Depending on the use case it is possible to rely on the global pointers to reach a world context, but it is very much not recommended, because you have no way to know which world to use. Also you’ll have to include Engine.h which is a big header file that will slow down intellisense and generate a compile warning.
Example :
Not from the blueprints you don’t have to. I might have misunderstood your issue.
For the automatic pin to work, you need to point the WorldContext meta properly. You point it to “WorldContextObject”, but your variable is named “contextObject”. The meta value must match variable name.