UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void ChooseFrom(TArray<UScenarioAction*> Actions);
I spent too long hitting my head against the resulting error message, which looks like this:
'void AMyPlayerController::ChooseFrom(const TArray<UScenarioAction *,FDefaultAllocator> &)': overloaded member function not found in 'AMyPlayerController'
This should work: I just want a function stub that the blueprint subclass implements. I tried every conceivable combination of annotations to the
UPROPERTY
and tried adding empty implementations in the cpp
file, knowing that there really
should be nothing wrong with the code.
It wasn't until I sat on the couch in the living room that I thought that the problem might be the parameter. Sure enough, if I took out the
TArray
parameter, everything worked as expected.
I little poking around the web inspired me to try passing the array by constant reference:
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void ChooseFrom(const TArray<UScenarioAction*>& Actions);
Sure enough, that did the trick. This seems like a place where the compiler could give a much friendlier message; there's nothing about the message it provides that makes me think that the parameter needs modification.
Hopefully writing this quick note on my blog will help save someone else an hour's aggravation—even if that someone is just future-me.
!
ReplyDeleteBeen trying to pass an array for a couple of days now with long compile times trying to figure this one out! And it was just a simple & that was needed haha! Thanks again :D Cheers
Glad to help!
Delete