Hi,
I’m having an issue with UMetaSoundOutputSubsystem::WatchOutput() when changing a MetaSound dynamically on an UAudioComponent.
Issue
WatchOutput() works correctly on the initial play, but after calling SetSound() and Play() again, the output callback never fires.
Repro Code
C++
void UMyAudioComponent::SetMetaSound(USoundBase* NewSound)
{
Stop();
SetSound(NewSound);
Play();
GetWorld()->GetTimerManager().SetTimerForNextTick(
this,
&UMyAudioComponent::RegisterWatcher
);
}
void UMyAudioComponent::RegisterWatcher()
{
if (!IsPlaying())
{
return;
}
if (UMetaSoundOutputSubsystem* Subsystem =
GetWorld()->GetSubsystem<UMetaSoundOutputSubsystem>())
{
Delegate.Unbind();
Delegate.BindDynamic(this, &UMyAudioComponent::OnOutput);
bool bResult = Subsystem->WatchOutput(
this,
TEXT("LastState"),
Delegate
);
UE_LOG(LogTemp, Warning, TEXT("WatchOutput result: %s"),
bResult ? TEXT("Success") : TEXT("Fail"));
}
}
Show more lines
Observed Behavior
-
First Play →
callback fires -
After
SetSound()→
callback never fires again -
WatchOutput()still returns true
Question
Is WatchOutput() expected to work after calling SetSound() on an existing AudioComponent, or is it only valid for the initial MetaSound instance?
Thanks!