so I am fairly new to C++ coding in general, not just when it comes to Unreal. I have some good knowledge in C#, Java and other languages however C++ is a different level to me.
I am trying to return a TArray from a void (UFunction) into BluePrint but I can not get it to work. I saw you can do it without using “return” but by putting it into the void parameters. That has worked but not with TArray for some reason and I don’t really understand why it’s not working.
Could anyone explain how it has to be done and show an up-to-date example that is actually working (in UE5)? That would be really helpful!
I might be wrong, but as far as my understanding is right this would not work since in a UFunction(BlueprintCallable) ‘&’ is not allowed or am I wrong?
I want it to work in a UFunction, C++ alone would not “help” me. ^^
But thank you so much, I am gonna experiment a little with the code you gave me.
It is allowed, but in BP it will be treated as an output parameter, so you can’t use it when calling the function like you would in C++;
You can use two array parameters, one as input, the other as output:
Looks really promising and is working. Thanks a lot. Now, does this work with any Type of TArrays? For example TArray<TSharedPtr>? How would I do that? This is what I couldn’t get to work and I thought I had to use ‘*’ as the compiler said but I didn’t know where nor how.
Yea, that seems to be the case for what I was trying to do but thats good to know, thanks a lot to both of you. That helped my understand a little more and I think I might be able to solve what I was trying to do!
Thanks again!
For whatever reason I couldn’t get any of the above solutions to work. I’m also quite new to C++. I was trying to return a TArray of Enums. Here’s the solution that ended up working for me: