I have 2 UENUM enumerated types: EGameResource and EGameResourceTypes.
UFUNCTION( BlueprintCallable, Category=MyGame)
void DefineResourceTypes( TArray<EGameResource> & Resources, EGameResourceTypes ResourceType );
The compiler sadly informs me that
OCResourceConversionDefinitions.h(26): error C2664: ‘void AOCResourceConversionDefinitions::DefineResourceTypes(TArray &,EGameResourceTypes)’ : cannot convert argument 1 from ‘TArray,FDefaultAllocator>’ to ‘TArray &’
What on earth is going on? How am I supposed to define an array of enums for a function exposed as a UFUNCTION?
OK – I seem to be able to work around it by changing the array to a TEnumAsByte:
void DefineResourceTypes( TArray<TEnumAsByte<EGameResource> > & Resources, EGameResourceTypes ResourceType );
Unfortunately, I am seeing that the array is, for some reason, getting treated as an OUTPUT parameter instead of the INPUT parameter it’s actually intended to be. What gives?
Dartanlla
(Dartanlla)
June 19, 2014, 8:31pm
3
If you add const in front of your reference type parameter it will make it an input on the blueprint:
void DefineResourceTypes( const TArray > & Resources, EGameResourceTypes ResourceType );
By default, pass by reference parameters are treated as outputs on blueprint nodes.
1 Like
Thanks – works like charm!
plojnitza
(plojnitza)
November 8, 2016, 11:05am
5
If you want the array to remain editable, try the UPARAM(ref)
After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...
Reading time: 1 mins 🕑
Likes: 13 ❤