- Home /
Loading Audio from Asset Bundles not working in Unity 5.2
After upgrading from Unity 4.6 from Unity 5.2, loading audio from asset bundles has stopped working.
Inside a coroutine, I load the AudioClips like this:
AudioClip audioClip = assetBundle.Bundle.LoadAsset(soundName, typeof(AudioClip)) as AudioClip;
yield return audioClip;
This used to work fine, but now this coroutine will finish without the AudioClip actually becoming playable. I can assign the audio clip to an audio source and Play() it without any exceptions being thrown, but the sound does not actually play and checking audioSource.isPlaying on the next line will return false.
I have tried calling audioClip.LoadAudioData() once the audio clip is loaded from the asset bundle and using a while loop to wait for audioClip.loadState to become "Loaded". e.g.
audioClip.LoadAudioData();
while (audioClip.loadState == AudioDataLoadState.Unloaded)
{
Debug.Log("Not Loaded");
yield return null;
}
However, the audio clip remains in the "Unloaded" load state indefinitely. If I inspect the audio clip using a breakpoint, I can see all of the information about the sound such as bit rate, length, etc.
To add to this strangeness, if I close the app after downloading these bundles and reopen it, the sounds play without any problems.
Is anyone having similar issues?
Having the same issue- very frustrating. Let me know if you figure it out. Good luck!
Answer by Daniel-Bengtsson · Feb 13, 2017 at 02:05 PM
We have the same issue as well. You can find what we've been able to dig up about the problem in this thread: https://forum.unity3d.com/threads/audioclip-loadaudiodata-returns-true-but-clip-remains-unloaded.455000/
Have you checked so that all the AudioClips get the same instanceID(per audio asset) or if loading the audio through www works as intended.
Also: Does your loading always work when you first start the application but breaks somewhere during load/runtime?
Your answer
Follow this Question
Related Questions
Why some audio files are not working in Unity? 0 Answers
Enemy death sound is buzzing 0 Answers
SFX fade out and then fade back in? 0 Answers
Altered audio quality on high frequencies sines 2 Answers
Audio/c#/unity Can i control the duration by time ? 1 Answer