Is there a way to assign an interface implementation in a blueprint?
To better illustrate, let’s say I have an interface to handle the animations:
UINTERFACE(BlueprintType)
class UAnimationHandler : public UInterface
{
GENERATED_BODY()
};
class MYGAME_API IAnimationHandler
{
GENERATED_BODY()
public:
virtual bool RunAnimation(const EAnimation Animation) = 0;
};
And I have an actor that holds a reference to it:
UCLASS()
class MYGAME_API AMyActor : public AActor
{
GENERATED_BODY()
private:
UPROPERTY(Category = "Animation", EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
TScriptInterface<class IAnimationHandler> AnimationHandler;
};
And an implementation for the interface:
UCLASS(Blueprintable)
class MYGAME_API UAnimationHandlerImpl : public UObject, public IAnimationHandler
{
GENERATED_BODY()
public:
bool RunAnimation(const EAnimation Animation) override;
private:
// ... Some pointers to animations
};
Then I create a blueprint for the implementation populating the animations.
And now I want to assign the interface implementation blueprint to a blueprint of AMyActor.
When opening the box to assign AnimationHandler there are zero options and trying to drag and drop did not help.
Is there assign a TScriptInterface through blueprint? Is there some configuration missing?
I could make AMyActor have a pointer to UAnimationHandlerImpl instead of a TScriptInterface but then having an interface loses its value.