FMOD, Asset Bundles and StreamingAssets

Hello!

We are making a game for mobile (iOS and Android) and are trying to reduce our build size by using Asset Bundles in Unity. Audio files take up a lot of space and might also be updated after the game has launched, so ideally we would like to store them in Asset Bundles as well.

This leads me to my questions:
How do I use FMOD with Asset Bundles? Is it possible at all, has anybody got this to work? I can pack the banks into an Asset Bundle and download that, but I’m not sure what is necessary to make them accessible inside the game then.

If FMOD does not work with Asset Bundles, is there any way we can download and use FMOD files during gameplay? Apparently, all the banks need to be located in the StreamingAssets folder which can only be edited in Unity Editor, it’s read-only in all builds.
Is there a good reason why they need to be in StreamingAssets, and is there a way around that?

Multiple games have used asset bundles with FMOD.

The modifications needed are:

  1. Change the code in EventManager.cs so that CopyToStreamingAssets() doesn’t copy files in StreamingAssets but instead sets them up as a binary TextAsset by changing the extension to .bytes and moving them under somewhere under Assets
  2. turn off the “load all banks at initialization” in FMOD Settings
  3. Implement your assetbundle streaming
  4. When you have your assetbundle use LoadAsset(name) to get the TextAsset object, use the bytes variables to get a byte[] and pass that into loadBankMemory() on the Studio system object FMODUnity.RuntimeManager.StudioSystem
1 Like

Thanks a lot, Nicholas! This is exactly the kind of information I was looking for.

So I guess there is no real reason that it is normally saved under StreamingAssets, it was merely a convenient choice?

Putting it under StreamingAssets lets us use platform native file IO for speed. Also using in-memory bank loading defeats the purpose of having any stream-from-disk sounds inside your banks. To get streaming you’d have to go assetbundle -> extract bank to temp file system -> pass path to FMOD.Studio.System.loadBankFile().

A future release (1.08.06) will have an option to do step 1 in the FMOD Settings, and a helper method in RuntimeManager for loading from a TextAsset.

1 Like

Thanks, that’s good to know.

I’ve already started implementing the steps described above. Will a future release also address the streaming problem with AssetBundles? It’s not too big of a workaround to extract the data to the file system to then stream it in, it’s just a bit slow and unnecessary.

There’s not really any other solution to streaming from a bank within an asset bundle. The asset bundle file on disk is not readable to us, and jumping back from native to managed code every time we do a block of file IO is not feasible.
If you have a large bank you want to stream, it might be best to bypass asset bundles and just download it straight to the file system and give fmod the path.

In such a case could I then not just upload the bank file to my sever instead of placing it into a bundle. Download it and use this method to load the bank directly

I’m afraid I don’t know much about the Unity side of things and all of our Unity experts are on Christmas / New Year’s leave right now, returning through the first couple of weeks in January. In the meantime I’ll do my best to help and if I get anything wrong it can be corrected when someone with greater expertise is available!

I think what you’re saying makes sense, but please bear in mind that this is a very old thread and it’s possible that some or all of the information above is no longer relevant or correct, and if the situation with streaming from asset bundles has changed over the last five years then this may no longer be sensible advice.