Expose static UFUNCTION to blutility

Ive tried a lot of methods but can’t get this working.

So I have a class, myClass, with UGlobalEditorUtilityBase as parent, doing so in order for my blutility to have myClass as a parent, and override a function. The thing is, the blutility is essentially just a calculation, so the UFUNCTION should be static, but I can’t seem to get it working, currently I’ve tried;

UFUNCTION(BlueprintImplementableEvent)
static void MyFunction();

but doesn’t work, ive also tried with other modifiers but no luck.

Thanks for any help

You just want BlueprintCallable, not blueprint implementable event.

I know if that doesn’t work you can stick it in a blueprint function library (UBlueprintFunctionLibrary) and it will work that way. You can look at ULeapMotionFunctionLibrary to get an idea.

edit: Misunderstood the issue. Sounds like this post is talking about what you want.

Yes I did also attempt BlueprintCallable, which came with it’s own errors. And also created an UBlueprintFunctionLibrary, thing is if the class inherits UBlueprintFunctionLibrary, then it can’t also inherit UGlobalUtility, and thus I Cant extend it with my Blutility.

What were the errors with BlueprintCallable?

And for the function library you don’t need to put it in the same class as the global utility.

Static function should work from any UObject, UBlueprintFunctionLibrary dont really have any importent stuff and it just to keep not-related-to-any-class static functions in one place

With blueprint callable, from output log:

1>Module.MyGame.cpp.obj : error LNK2019: unresolved external symbol “public: static void __cdecl UMyClass::FuncionTest(void)” (?FuncionTest@UMyClass@@SAXXZ) referenced in function “public: void __cdecl UMyClass::execFuncionTest(struct FFrame &,void * const)” (?execFuncionTest@UMyClass@@QEAAXAEAUFFrame@@QEAX@Z)
1>MyGame.generated.cpp.obj : error LNK2001: unresolved external symbol “public: static void __cdecl UMyClass::FuncionTest(void)” (?FuncionTest@UMyClass@@SAXXZ)

Yeah I should have been able to get BlueprintCallable working, it seems like the simplest way to do this, not sure why it isn’t though, am I missing something?

UCLASS()
class  UMyClass :public UGlobalEditorUtilityBase
{
    GENERATED_BODY()

public:

    UFUNCTION(BlueprintCallable, Category = "Editor")
    static void FuncionTest();

};

note I have nothing in my .cpp, should I?
Also since my intentions are to use this function in a blutility, there is 0 runtime code involved at all, all functionality in editor mode.

Oh. You want a static function defined in BP that’s available to call in C++? Is that what you’re looking for? Or do you want a new event node that you can drop anywhere in your BPs?

I’d check out this post.

Yes the error you are getting is linker error because you don’t have code in cpp, he finds mention of your static function in definitions of generated bineries but can;t find code for it, so he can’t link binery code to the function and there for link it toghther with rest of the code. And htis has nothing to do with UFUNCTION, you would get this error either way if you use it or not

So as mrooney asks, what really you want to do here? Note blueprints don’t support static events, if you want to make event it needs to be in object and you need to “spawn” that object first in order to use it. If you want global-like event placing it in AGameMode or AGameInstance would be good, but there many other possibilities

So the static function would be defined in C++, it would then be overridden by a Blutility (not BP), so that I can call that function from C++ and would run the Blutility.