Search Unity

Question Loading modder's assetbundles

Discussion in 'Asset Bundles' started by knackname, Mar 14, 2021.

  1. knackname

    knackname

    Joined:
    Mar 14, 2021
    Posts:
    3
    I want to setup a way for modders to include assetbundles in their mods and and those assets loaded. As a test I have a script running:

    Code (CSharp):
    1. var path = @"mods\myMod\Assets";
    2. var bundle = AssetBundle.LoadFromFile(path);
    but bundle is always null. The assetbundle is generated with the same version of unity (2019.4) as the game running the scrips. I tried putting it in the streaming assets dir and using the full path from c with Application.dataPath but nothing works. I confirmed the file exsists with System.IO and I successfully wrote a script to load the bundle in the project that generated it. is there something I'm missing? I just doesn't work in the mod script.
     
  2. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    Result will be null if bundle is not found or incompatible.
    Try placing bundle inside the root dir where player.exe is, give it extension for the posterity's sake (*.unity3d) and load it
    var bundle = AssetBundle.LoadFromFile("muhbundle.unity3d)";

    If it wont load then you've built it wrong. Are you using AssetBundleBrowser or you own custom script workflow?
     
  3. knackname

    knackname

    Joined:
    Mar 14, 2021
    Posts:
    3
    I was using the wrong version of unity... once I corrected that the bundles worked