How to load a Unity Asset Bunde file from web/url



Make an empty object on your scene and attach this script to it:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using System;

public class BundleWebLoader : MonoBehaviour
{
	public string bundleUrl = "http://localhost/assetbundles/testbundle";
	public string assetName = "BundledObject";
	
    // Start is called before the first frame update
    IEnumerator Start()
    {
        using (WWW web = new WWW(bundleUrl))
		{
			yield return web;
			AssetBundle remoteAssetBundle = web.assetBundle;
			if (remoteAssetBundle == null) {
				Debug.LogError("Failed to download AssetBundle!");
				yield break;
			}
			Instantiate(remoteAssetBundle.LoadAsset(assetName));
			remoteAssetBundle.Unload(false);
		}
    }


}

Don’t forget to specify your correct url to the asset bundle you want to reach and the name of object you need.

Watch this video demonstration to see more:

loading...

4 thoughts on “How to load a Unity Asset Bunde file from web/url

  1. My 3d model is getting loaded at some random position, i want to load the 3d model as the child of ImageTarget and instantiate it at 0,0,0. How can that be done ??

  2. hi. i need a way to permanent add downloaded objects, just like add DLC to a game. because i dont want to download them again and again. this tutorial can do it?

Leave a Reply

Your email address will not be published. Required fields are marked *