Search Unity

Loading AudioClips from AssetBundles does not work in Unity 5

Discussion in 'Audio & Video' started by fredrik-larsson, Oct 5, 2016.

  1. fredrik-larsson

    fredrik-larsson

    Joined:
    Nov 3, 2015
    Posts:
    29
    Hi!

    After upgrading a project from 4.6.5f1 to 5.4.0f3 we've found a severe problem with loading audioclips from assetbundles in Unity 5.

    http://answers.unity3d.com/question...o-from-asset-bundles-not-working-in-un-1.html
    http://answers.unity3d.com/questions/1096450/loading-audio-from-asset-bundles-not-working-in-un.html

    And many more appears to have the same problem. The clip is correctly recognized after unpacking the assetbundle but the AudioData for the clip is not loadable and thus the clip can never be played. Even after explicitly calling:

    Code (CSharp):
    1.            
    2. if(clip.loadType == AudioClipLoadType.Streaming)
    3. {
    4.      bool success = clip.LoadAudioData();
    5.      if (!success)
    6.           Debug.LogError("Could not load AudioData for: " + clip.name);
    7. }
    The LoadAudioData() function returns true marking that it was successful in loading the audiodata but this produces the
    exception in the first link above.

    What is the correct way to place AudioClips in assetbundles and load them correctly in Unity 5?
     
    Last edited: Oct 5, 2016
    SomeTallGy likes this.
  2. SomeTallGy

    SomeTallGy

    Joined:
    Jan 3, 2014
    Posts:
    18
    Sadly, this seems to be a bug on Unity's end. I have spent the last 2 days trying just about everything to get audio clips to play from assetbundles. We seem to be at the mercy of the Unity developers on this one.
     
    fredrik-larsson likes this.
  3. fredrik-larsson

    fredrik-larsson

    Joined:
    Nov 3, 2015
    Posts:
    29
    Have you found any workaround that can be applied on a project wide basis? I'm currently in a project which sports around 20gb of assetbundles and going through all assets after upgrading to Unity 5 is not really an option.

    It's possible to set the AssetBundle AudioClip to not use streaming and instead be "Compressed In Memory" which allows you to check the "Preload Audio Data" box on the AudioClip settings which then will allow you to play the AudioClip after loading it from an AssetBundle.

    This however is not really a good solution as larger AudioClips such as music files which you'd like to be able to stream instead are not possible to be built into an AssetBundle with the streaming option....

    voice_clip.JPG

    You can also check my post here for some more information about this: https://forum.unity3d.com/threads/l...assetbundles-in-unity-5-does-not-work.434881/


    But yes, as you said. This definately appears to be quite a troublesome bug when using assetbundles