Search Unity

Running into the 'Unable to open archive file' error when loading AssetBundle on WebGL build

Discussion in 'Asset Bundles' started by MBezzina, Jun 15, 2021.

  1. MBezzina

    MBezzina

    Joined:
    Jan 6, 2021
    Posts:
    2
    As the title explains, I'm trying to set a variable using the AssetBundle.LoadFromFile() method and am encountering the error 'Unable to open archive file: filepath'. When I click on my filepath link in the Console, it downloads the file I expect and is seemingly just not setting my loadedAssetBundle variable properly.

    I currently have prefabs labeled under the AssetBundle(s) I'm trying to save, but have also tried simple scenes (ie just a cube) and simpler prefabs as well. I get the same error every time and have been halted by this issue. I've posted some images of my code and the console error as well to help clarify how it's set up. Any help / advice is very much appreciated. Thanks!
     

    Attached Files:

  2. MBezzina

    MBezzina

    Joined:
    Jan 6, 2021
    Posts:
    2
    FIX: I believe the issue was solved by first bringing in the file as a UnityWebRequest and then using DownloadHandlerAssetBundle.GetContent() to turn it into a usable AssetBundle. Here's the change that seems to have cleared up the issue.
     

    Attached Files:

unityunity