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?