Blueprint Native Event error when using FString parameter

I’m a bit confused by this one. It seems that I can only use BlueprintNativeEvents with certain parameters?

This compiles and runs:

UCLASS()
class DEBUG_API UMyUserWidget : public UUserWidget
{
	GENERATED_BODY()
	
public:
	UFUNCTION(BlueprintNativeEvent, Category = "Files")
	void	Setup();
};

This errors out:

UCLASS()
class DEBUG_API UMyUserWidget : public UUserWidget
{
	GENERATED_BODY()
	
public:
	UFUNCTION(BlueprintNativeEvent, Category = "Files")
	void	Setup(FString input);
};

There are a lot of different errors that I can get from this problem, depending on the project. On an empty project, with this configuration, I get:

MyUserWidget.cpp(14): error C2511: 'void UMyUserWidget::Setup_Implementation(FString)': overloaded member function not found in 'UMyUserWidget'

If I change to the GENERATED_UCLASS_BODY macro and define a constructor, I get:

Debug.generated.cpp(18): error C2511: 'void UMyUserWidget::Setup(const FString &)': overloaded member function not found in 'UMyUserWidget'

If I change the signature to be const FString& input, it works without complaint.

This seems like a bug.

Hello,

This is actually working as intended.

The reason behind having to add the & is because a direct reference will let the event know that it is an input pin. Because this is a Native Event, it requires an input, which would explain the compiler error you are getting when not adding the & to specify that the parameter you are passing is in fact, an input.

Have a great day

Thank you for the answer. My followup, then, would be how do I pass an FString as an output? Usually I pass by reference for outputs, but if I have to pass by reference for an input, there is a conflict there.

You’re correct, take a look at the documentation linked below, as I think it will provide a bit of information that could help clarify things for you:

Let me know if that helps