Bind interface function with delegate

Interface:

// This class does not need to be modified.
    UINTERFACE(MinimalAPI, BlueprintType)
    class UEventInterface : public UInterface
    {
    	GENERATED_UINTERFACE_BODY()
    };
    class AGAME_API IEventInterface
    {
    	GENERATED_IINTERFACE_BODY()
    
    	UFUNCTION(BlueprintImplementableEvent, category = "Event")
    	void OnTestEventHandler(int NewLevel);
    };

Delegate:

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FTestSignature, int, NewLevel);

/**
 * 
 */
UCLASS()
class AGAME_API ATestGameState : public AGameState
{
	GENERATED_BODY()

public:
	// Called when the game starts
	virtual void BeginPlay() override;

	UPROPERTY(BlueprintAssignable, meta = (DisplayName = "OnTestEvent"))
	FTestSignature OnTestEvent;

	UFUNCTION(BlueprintCallable, category = "Event|Level")
	void RegisterEvents();
};

I wan bind event with interface, like:
void RegisterEvents()
{
OnTestEvent.AddDynamic(UEventInterface, &UEventInterface::OnTestEvent);
}

How should I implement, bind the interface function with OnTestEvent

1 Like