Loading asset bundles directly from Streaming Assets

*I realize this is a beta forum, but since it is related to asset bundles, i figured i’d post my question here. If not, please move to the appropriate forum, and let me know which forum i should post to in the future…

I’d like to know if it’s possible to load asset bundles directly from Streaming Assets**,** on all platforms ?

I recall seeing an improvement some time ago (can’t find it now) that support for this was added. But i may be wrong on that.

So, is this supported right now? what is the proper way of loading asset bundles from streaming assets at the moment?

You can, you just have to use WWW or WebRequest to do it…

This is fixed in 2017.1b2, I want to say it was fixed in earlier versions, but still trying to track down the PR to get more exact details. Will get back to you on this.

So digging a bit more into this one and found the fix. It was first fixed in 5.4.0f2, then backported to 5.3.6p3.

@Ryanc_unity is this the fix where AssetBundle.LoadFromFile works with streaming assets on Android? i believe i tested this and it didn’t work.

yes, here’s are specific notes for those versions and the respective lines pertaining to this:

https://unity3d.com/unity/qa/patch-releases/5.3.6p3
(763293) - AssetBundles: Fixed AssetBundle.LoadFromFile usage with Application.streamingAssetsPath on Android.

https://unity3d.com/unity/whats-new/unity-5.4.0
[763293] Asset Bundles: Fixed AssetBundle.LoadFromFile usage with Application.streamingAssetsPath on Android.

@Ryanc_unity we just tested this (Unity 5.5.3p1) and it doesn’t seem to work.

We have our own “asset bundle manager” object that loads Asset bundles from StreamingAssets (using AssetBundle.LoadFromFileAsync). We are now directly attempting to load from Application.streamingAssetsPath but it keeps returning null and the bundles cannot be loaded.

Is there a chance that this is a regression, or are we doing something wrong ?

Here’s the code that essentially loads the bundles:

private IEnumerator LoadAssetBundleFromStreamingAssetsCoroutine(string bundleName, string path, Action<AssetBundle> handler)
{
    // Loading asset bundle
    var req = AssetBundle.LoadFromFileAsync(path);
    yield return req;

    Assert.IsNotNull(req.assetBundle, "AssetBundleLoader : asset bundle wans't loaded from streaming assets");
    Assert.IsNotNull(handler, "No callback handler");
 
    if (req.assetBundle == null)
    {
        handler(null);
        yield break;
    }
 
    handler(req.assetBundle);
}

NOTE: we’re not keeping our files directly under streaming assets, they are stored under a few subfolders (not sure that matters).

Never mind, ignore my previous message. it works fine.