Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Trying to catch FMOD errors

Discussion in 'Editor & General Support' started by diekeure, Apr 7, 2017.

  1. diekeure

    diekeure

    Joined:
    Jan 25, 2013
    Posts:
    221
    Hello,

    We are loading sound from assetbundles. All usually works fine, but sometimes (indeed, sometimes), the audio cannot be loaded from the assetbundle, spawning error messages:

    Cannot create FMOD::Sound instance for resource archive:

    In our code we have a coroutine that looks like this:

    Code (CSharp):
    1. while (nextClipToPlay.loadState != AudioDataLoadState.Loaded && nextClipToPlay.loadState != AudioDataLoadState.Failed)
    2.     yield return nextClipToPlay.LoadAudioData();
    3.  
    4. if (nextClipToPlay.loadState == AudioDataLoadState.Loaded)
    5. {
    6.    audioSource.clip = nextClipToPlay;
    7.    audioSource.Play();      
    8. }
    Sometimes it gives me this error on line 2, and when that happens, the loop just continues forever; the loadstate does not change into Failed, thus the coroutine never ends. Spawning error messages each frame.

    I have to stress the "sometimes": on the same device, with the same asset bundles, it mostly works, but sometimes it doesn't.

    Question is twofold:
    • Is there a way to fix this error?
    • But maybe better: is there a good way to catch this error so I can interrupt the loading?

    Thanks for any help or insight you can give!
    Alex

    Edit: this is on Unity 5.4.4p4
     
  2. diekeure

    diekeure

    Joined:
    Jan 25, 2013
    Posts:
    221