问题
我通过可寻址资产系统()获得AudioClip,并将其传递给AudioSource播放。如果我将PlayMode设置为“使用资产数据库”,它会运行得很好,但是如果我指定使用现有的构建,它就不会运行。请帮帮我。
我试过的东西
但当我在编辑器中查看它时,AudioClip没有在AudioSource中注册,VoiceTrack.clip = clip也没有正常完成。
版本
2021.3.10f1
相关部分中的代码
main.cs
public async UniTask ExecuteAsync(CallInstReference reference, InstRunner runner, CancellationToken cancelToken)
{
AudioClip clip = await Addressables.LoadAssetAsync<AudioClip>(clipAddress.Get());
reference.world.callSoundManager.PlayVoice(clip, duration );
Addressables.Release(clip);
}callSoundManager.cs
public void PlayVoice( AudioClip clip , float duration = 0.2f , bool loop = false)
{
Debug.Log(clip.name + " voiceStart"); //currect clip name displayed.
VoiceTrack.clip = clip; //no clip attached the audioSource in Editor
VoiceTrack.loop = loop;
VoiceTrack.Play();
VoiceTrack.DOFade(1f, duration);
}如有遗漏,请评论。谢谢。
发布于 2022-09-22 08:21:38
自我解决。我试过
Addressables.LoadAssetAsync(clipAddress.Get());=等待
AudioClip剪辑
但我似乎需要拿出手柄,等待一个单独的任务。抱歉打扰你了。下面的代码工作正常。
AsyncOperationHandle句柄=Addressables.LoadAssetAsync(密钥);等待handle.Task;
如果(handle.Status == AsyncOperationStatus.Succeeded)结果= handle.Result;
https://stackoverflow.com/questions/73808968
复制相似问题