Search Unity

Will "AssetBundle.LoadFromFile" copies the entire ab file into memory for future use?

Discussion in 'Asset Bundles' started by Solidcomer, Jan 10, 2020.

  1. Solidcomer

    Solidcomer

    Joined:
    Sep 12, 2017
    Posts:
    51
    I've read AssetBundle tutorial by Unity Technologies, the tutorial was suggested for Unity 2017.

    One chapter says,
    "AssetBundle.LoadFromFile .... On desktop standalone, console, and mobile platforms, the API will only load the AssetBundle's header, and will leave the remaining data on disk. The AssetBundle's Objects will be loaded on-demand as loading methods (e.g. AssetBundle.Load) are called or as their InstanceIDs are dereferenced."

    And my questions are,
    1. Is the case mentioned above still true in Unity 2019.2?

    2. If it's still true, I think "AssetBundle.LoadFromFile" only reads a very small amount of data from disk each time it's called, and Unity won't read, from disk, the actual data of assets contained in the AB file until methods, e.g. AssetBundle.Load(), are called for those assets? Is this correct?

    3. If those are all true, for example, on Android, there is a big AB file that contains a 200MB mp3 asset. When I call"bigABFilePath"), Unity will only read/load like "1KB" (header) but not 200MB from disk, thus responds very quickly; and after that, when I call bigABFile.Load("mp3Name"), then Unity will now read/load 200MB from disk, thus causing a slow frame. (What I care is the time consumption of AssetBundle.LoadFromFile, not memory usage.) Is this example true generally speaking?


    I created asset bundle files with BuildAssetBundleOptions.ChunkBasedCompression.
    I'm currently writting some utils to manage the loading and releasing of assets VIA asset bundle, if those mentioned above are all correct, hopefully I don't need to support the Async version of AssetBundle.LoadFromFile, but only the asynchronous way of loading assets.

    Thanks a lot for reading my thread.
     
    Last edited: Jan 10, 2020
unityunity