Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

StreamingAssets vs. Resources.Load

Discussion in 'Android' started by kromenak, Jun 30, 2015.

  1. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    266
    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:
    1) 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.
    2) 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.
    3) 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!
     
    AbleArcher likes this.
  2. JaviOverflow

    JaviOverflow

    Joined:
    May 22, 2015
    Posts:
    12