How to mount OBB file from unity?

So, Unity has the option to split the application apk into a main apk plus an OBB: Unity - Manual: APK expansion files

However, this generates only a single OBB and I think that one’s limited to 2GB.

How can I mount custom OBB files (in particular encrypted ones) - for example OBB files that contain a couple of assetbundles - from within Unity and then access the contained assetbundles?

As your linked documentation page states, Unity will only mount OBB files if they contain a file with build-id that matches build-id in the app’s manifest. If your whole OBB file is encrypted, Unity will not be able to read the contents of the OBB file and it will not be loaded.
You could try encrypting individual assetbundles instead of the whole OBB file. Then once the OBB is loaded by Unity, you would read the encrypted asset bundle, decrypt it and then load it with AssetBundle.LoadFromMemory.

I thought AssetBundles didn’t support encryption?

AssetBundles don’t support encryption out of the box (just like OBB files). However if you are manually encrypting files, you have an option to encrypt individual AssetBundles instead of the whole OBB. Then during runtime you would have to decrypt AssetBundle into the memory and then you could load it from the memory.

OBB files support encryption: https://developer.android.com/reference/android/os/storage/StorageManager#mountObb(java.lang.String,%20java.lang.String,%20android.os.storage.OnObbStateChangeListener)

decrypting the whole assetbundle into memory would require too much ram, our assetbundles are several 100MB large and there are a lot of them

Right, I should’ve been more specific. OBB files created and loaded in Unity do not support encryption.

In that case the best option is probably to encrypt individual assets that are placed inside of the asset bundle. At least I don’t know a better way.

@JuliusM our assetbundles are are Streamed Scene Asset Bundles. Is there any way to encrypt the assets contained in a Streamed Scene Asset Bundle?