【发布时间】:2022-10-06 22:50:17
【问题描述】:
问题
我通过 Addressable Asset System 获取 AudioClip 并将其传递给 AudioSource 进行播放。如果我将 PlayMode 设置为 Use Asset Database,它可以正常播放,但如果我指定 Use Existing Build,它就不会播放。 请帮我。
我尝试过的事情
-
我从 Addressable Group 窗口执行了 New Build > Default Build Script,但情况并没有改善。另外,即使执行了Clean Build,也是一样的。
-
原以为自己采集没有做完,用DebugLog显示了采集到的AudioClip的名字,但是显示正常,认为采集好了。
但是当我在编辑器中查看时,AudioClip 没有注册到 AudioSource 并且 VoiceTrack.clip = clip 没有正常完成。 -
我尝试将 AssetBundleCompression 设置切换为 UnCompressed,但没有效果。
版本
- Unity 版本 2021.3.10f1
- Addressables 版本 1.19.19
代码在相关部分
主文件
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); }如果有什么遗漏,请评论。谢谢你。