Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How does LoadFromFile work?

Discussion in 'Asset Bundles' started by User340, Feb 24, 2020.

  1. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    When you call AssetBundle.LoadFromFile() does it load the whole bundle into memory or just header? I've got a 500 MB Asset Bundle and LoadFromFile is taking a long time.
     
  2. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    It depends on your bundle compression settings. If the bundle was LZMA compressed, then the entire file will be first decompressed into RAM before you can load assets from it. When using uncompressed, LZ4, or LZ4HC, only the bundle header is loaded, with individual assets being loaded directly from disk when requested.

    Basically, using LZMA causes LoadFromFile to behave like LoadFromMemory. I have yet to find a valid use case for it.
     
    User340 likes this.
  3. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Ah, that makes sense. Thank you!