Event dispatcher calling code function

Viewed 4228

I have a question about event dispatchers. I've created dispatcher in my code like this:

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSoundPausedDelegate, bool, isSoundPaused);

UPROPERTY(BlueprintAssignable)
        FSoundPausedDelegate AudioPause;

This works perfectly fine in blueprints. However I don't really know, how can i make it to call function in code?

I guess it's going to be something with:

AudioPause.AddDynamic(this, &UAudioController::OnDelegateBroadcast);

What shall I bind it to? This is meant to broadcast value every time i pause/unpause my audio in blueprint and then execute more code logic depending on broadcasted value.

This is how my function looks like:

void UAudioController::OnDelegateBroadcast(bool SoundPaused)
{
    if (SoundPaused == true)
    {
        SoundPause = true;
        GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("True"));
    }
    else
    {
        SoundPause = false;
        GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("False"));
    }
}
2 Answers
Related