I have created a Blueprint interface in C++, like this:
/// Implemented by dialogs and menus that can be controlled with keyboard and gamepad
class NUCLEX_API IButtonControllableDialog {
GENERATED_BODY()
/// Accepts the currently selected dialog option
public: UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, Category="UI")
void Accept();
/// Cancels the currently selected dialog
public: UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, Category="UI")
void Cancel();
// ...
};
And inherited said interface in a pure Blueprint class:
Now I thought my C++ player controller could be given a property like this:
/// Dialog to which input is currently being sent (can be null if no dialog is active)
public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient, Category="UI")
TScriptInterface<IButtonControllableDialog> ActiveDialog;
But as I found in the Interfaces in C++ wiki article, that does not work for Blueprint interfaces implemented in Blueprint. Instead, I have to check:
this->ActiveDialog->GetClass()->ImplementsInterface(UButtonControllableDialog::StaticClass())
Fine.
But if I assign the [FONT=courier new]ActiveDialog property in Blueprint, even though it compiles fine, it instead assigns [FONT=courier new]NULL.
It works if I change the property type to [FONT=courier new]UObject *, but that would totally remove any type information. Blueprinters could assign literally anything :-/
Funnily, if I create a class with an [FONT=courier new]IButtonControllableDialog property in Blueprint and nativize it, the same [FONT=courier new]TScriptInterface<IButtonControllableDialog> property is generated.
How can I create a property of type [FONT=courier new]IButtonControllableDialog that works for both C++ and Blueprint classes?