BindUFunction with Variable Capture in C++

Is this possible?
If yes, how is it done?


You could bind a lambda and then capture what you want. Even if it needs to be an UFunction just make a wrapped with the lambda and call your inner UFunction with the captured members.

Hey Moss, would it be possible for you to post a code snippet showing how to do that? I’m having a hard time figuring out how to get a UFunction pointer from a lambda. Thanks!

is bumping possible?

You could do something like:

void UMyClass::FunctionWithVar(const FString& MyVar, TFunction<void(const FString&)> InFunction)
    MyLambdaHandle = OnMyDelegate.BindStatic([MyVar](TFunction<void(const FString&)> callback) {
    }, InFunction);

    // TODO: You have to track MyLambdaHandle to be able to unregister it when needed

Note: It’s all hand written and may not compile