For a project I’m working on, I need to dynamically load large blobs of binary data (up to 30 or 40MB). My solution thus far has been to store those files in StreamingAssets and load the data on demand using the FileStream system. This works pretty well in the editor and on iOS, but performance seems to be worse on Android (causing a hitch in gameplay). I’m guessing this might be because the assets need to be dynamically unzipped from the APK file using the WWW class.
Based on this, I’m considering a couple solutions beyond continuing to use StreamingAssets:
- Unzip my binary data from the APK and save it to the Android file system before the data is needed (perhaps on game initialization). Then, I can load that data without having to wait for the data to get pulled out of the APK.
- Switch over to using Unity’s Resources system. I can put my binary blobs into the Resources folder, and then I should be able to load it at runtime.
- AssetBundles? Not sure if they would be appropriate for this purpose.
Does anyone have any anecdotal data or thoughts on what approach would be best in this scenario? I’m a bit worried about the Resources system pre-loading data or something - due to memory constraints, I really need this data to ONLY be loaded into memory when I tell it to and unload when I tell it to. Does Unity’s Resources system have to deal with the same Android APK decompression issue as StreamingAssets?
Any thoughts/ideas much appreciated!