AudioClips Retrieved in the Addressable Asset System Does Not Play

Asked 2 years ago, Updated 2 years ago, 410 views

The AudioClip obtained from the Addressable Asset System is passed to AudioSource and will not play. If you set PlayMode to Use Asset Database, it will play normally, but if you change it to Use Existing Build, it will no longer play.
It also does not play in Windows builds.
There are no error messages on the console.
Please let me know if you have any idea.

Please let me know if there is anything missing.
I'm in trouble because I can't find a report of this phenomenon online.
I look forward to your kind cooperation.

Tried

New Build > Default Build Script from
on the Addressable Group window Addressable has been run.We also ran the Clean Build. None of them improved.

I thought that the AudioClip acquisition itself might have failed, so I tried to display the name of the Clip retrieved on the console in DebugLog. However, a successful clip name appeared in the log.
When I checked if AudioClip was passed to AudioSource on the Editor at the same time, it was left as None.
AudioClip-like data has been retrieved, but audiosource.clip=clip
We believe that the configuration cannot be completed successfully.

I changed the AssetBundleCompression setting to UnCompressed, but there is no change.

Run Environment

Unity Version 2021.3.10 f1
Addressables Version 1.19.19

Code of interest

main.cs

public async UniTask ExecuteAsync (CallInstReference reference, InstRunner, CancellationToken cancelToken)
{
    AudioClip=waitAddresses.LoadAssetAsync<AudioClip>(clipAddress.Get());
    reference.world.callSoundManager.PlayVoice(clip, duration);
        Addressables.Release (clip);
    }

callSoundManager.cs

public void PlayVoice (AudioClip clip, float duration=0.2f, pool 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);

    }

unity3d unity2d

2022-09-30 22:05

1 Answers

I solved myself.
Direct

AudioClip=waitAddresses.LoadAssetAsync<AudioClip>(clipAddress.Get());

I was waiting, but it seems that I had to take out the handle and wait for the task separately.Sorry for the trouble.

The code below worked fine.

AsyncOperationHandle<T>handle=Addressables.LoadAssetAsync<T>(key);
wait handle.Task; if(handle.Status==
AsyncOperationStatus.Successed) result=handle.Result;


2022-09-30 22:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.