Daily Unreal Column #58 - Blueprint Parameter by Reference
When we declare a blueprint callable function parameter as a reference, by default, Unreal will treat it as a function output. But what if we want this parameter to be an input to a function?
The only solution for this is to use a UPARAM
macro. Let’s take a look at the following function declaration.
UFUNCTION(BlueprintCallable)
static void MyFooFunction(int32 Param, int32& OutParam);
This is how it will look like when we call it in a blueprint graph.
As you can see, the OutParam
is treated as a function output parameter. Lets modify the function declaration as following.
UFUNCTION(BlueprintCallable)
static void MyFooFunction(int32 Param, UPARAM(Ref) int32& OutParam);
With the above declaration, the function’s node will look like this.
As we can see, now the OutParam
is treated as an input parameter passed by reference.