【发布时间】:2017-10-06 19:45:09
【问题描述】:
我不太明白,所以我在这里问。我正在使用下面发布的功能生成 AudioComponent。它附加了 10 秒的 SoundCue。然后我在 2 秒后暂停它并设置延迟 30 秒。然后我想取消暂停我的声音。问题是,我的调度程序在它之前触发,我的声音甚至无法取消暂停。它会被摧毁吗?有什么办法可以预防吗??
UAudioComponent* MyAudioClass::LatentSound2D(UObject* WorldContextObject, struct FLatentActionInfo LatentInfo, class USoundBase* Sound, float VolumeMultiplier, float PitchMultiplier, float StartTime, class USoundConcurrency* ConcurrencySettings, bool bPersistAcrossLevelTransition)
{
MyAudioClassObject= NewObject<MyAudioClass>();//handle needed to bind delegate
UAudioComponent* AudioComponent = UGameplayStatics::CreateSound2D(WorldContextObject, Sound, VolumeMultiplier, PitchMultiplier, StartTime);//Create AudioComponent
MyAudioClassObject->BindDelegate(AudioComponent);//Bind delegate to AudioComponent
AudioComponent->bAutoDestroy = false;
AudioComponent->bAllowAnyoneToDestroyMe = false;
AudioComponent->AddToRoot();
AudioLatentBind(WorldContextObject, LatentInfo, AudioComponent); //add latent action for this audio component (wait till it ends)
return AudioComponent;
}
我绑定的委托是 OnAudioFinished。如果有任何不清楚的地方,请告诉我。我真的需要帮助:(这就是蓝图中的样子
【问题讨论】:
-
你可以至少告诉我们你正在使用哪个库来提供这些类...我们不是读心术的人。
-
我刚刚检查了这个,似乎我的 AudioComponent 停止了,这就是 OnAUdioFinished 触发的原因。但是我不知道如何阻止这个 stop() 调用。
-
当然
#include"MyProjectCodeFunctionLibrary.h" #include"GameFramework/Actor.h" #include "Object.h" #include "AudioDevice.h" #include "ActiveSound.h" #include "LatentActions.h" #include"MyAudioClass.generated.h"这些是我包含的文件。抱歉,我是新手,还不知道哪些信息对其他人有价值 -
仅仅列出包含并不能告诉我们这是什么库。它叫什么名字?项目网站和文档在哪里?
-
函数解释:BindDelegate 是自解释的。它只是将 OnAudioFinished 绑定到我的 AudioComponent。 AudioLatentBind 正在添加新的潜在动作,它只是等待获取音频已完成的信号,然后允许使用 exec pin 继续。
标签: c++ audio unreal-engine4