I’m currently working on saving AssetBundles to a user’s device in Unity after downloading them. However, I’ve encountered a challenge. I’m trying to download an AssetBundle, save it locally, and then load it from there, but I’m running into an issue when attempting to save the bundle.
The error I’m getting is:
“NotSupportedException: Raw data access is not supported for asset bundles”
This happens when accessing downloadHandler.data after downloading the AssetBundle.
I’ve tried using DownloadHandlerAssetBundle.GetContent() for fetching the AssetBundle, but the saving process is still giving me trouble.
You should not use UnityWebRequestAssetBundle when you just want to download the file. This class is specifically designed to efficiantly load and decode AssetBundles on the fly. As you can read in the documentation:
In addition, the DownloadHandlerAssetBundle streams data into a ringbuffer and decompresses the data on a worker thread, saving many memory allocations compared to downloading the data all at once.
Since this handler uses a ring buffer and directly processes the data on a seperate thread, this handler does not give you access to the raw data as it doesn’t hold the data in memory.
1 Like
Thank you, Bunny, for helping me! I have now understood and fixed the code. I have attached an image of the fixed code. If anyone is facing the same issue, refer to that image to learn how to save the asset bundle to disk.