I seem to be unable to pass a custom UStruct to a BlueprintImplementableEvent in 4.15, even in a clean project. To do this, I set up a custom player controller that overrides BeginPlay() and calls two functions, defined as such in MyPlayerController.h:
USTRUCT(BlueprintType)
struct FMyStruct
{
GENERATED_USTRUCT_BODY()
int32 TestInt;
FText TestText;
};
UCLASS()
class MYPROJECT_API AMyPlayerController : public APlayerController
{
GENERATED_BODY()
public:
virtual void BeginPlay() override;
UFUNCTION(BlueprintImplementableEvent)
void BP_LoadTArray(const TArray<FMyStruct> &MyStructArray);
UFUNCTION(Blueprintimplementableevent)
void BP_LoadStruct(const FMyStruct& MyStruct);
};
MyPlayerController.cpp is pretty simple:
void AMyPlayerController::BeginPlay()
{
Super::BeginPlay();
FMyStruct NewStruct;
NewStruct.TestInt = -1;
NewStruct.TestText = FText::FromString("test");
TArray<FMyStruct> MyStructArray;
MyStructArray.Add(NewStruct);
// testing whether we can pass a struct array by const ref
// is it empty?
if (MyStructArray.Num() > 0)
{
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, MyStructArray[0].TestText.ToString());
}
BP_LoadTArray(MyStructArray);
// testing whether we can pass a struct itself
// is it empty?
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, NewStruct.TestText.ToString());
BP_LoadStruct(NewStruct);
}
Then, I made a Blueprint Child class of MyPlayerController, which implemented the previously defined Functions/Events, just to place some BreakPoints and check whether the events have data in the passed Structs. Simply put, they don’t. Does anyone know why?