Pass-By-Reference output

In a blueprint function, there is any way to return a reference to a struct/array of structs? You can do it in the input, why not in the output?

No, the Blueprint VM doesn’t support returning types by-reference.

You can have a non-const reference parameter that will appear as an output pin on the BP node, but you’re still getting back a copy.

void MyFunc(const FThing& Input, FOther& Output);

Structs are basically treated as value types. If you want to be able to pass large amounts of data around without copying it then you’ll have to put it inside an object (which you’ll be able to pass/return by-pointer).

FWIW references don’t matter much to BP functions, as internally they always copy inputs in by value, and copy outputs back by value.

2 Likes

The only “way” in blueprint is to use Macro.

2 Likes

Unless I’m mistaken, a macro can’t output a reference either…

Just try with a macro. It works.