Gin Rummy Indian Rummy Nine Men's Morris and more Air Attack

Wednesday, 20 January 2016

Downloading asset bundles and loading scene from it with Unity 5.x

In this post we will create an asset bundle with simple scene and then we will load this from a different scene.

Creating the Asset Bundle

Let myscene be the name of the scene which we want to put in to an asset bundle. To create an asset bundle click on to the scene and  at the bottom of your inspector window give a name for your AssetBundle.

We will need a script to export our scene as an asset bundle. Use the following editor script code export the asset bundles.
using UnityEditor;

public class CreateAsset
    [MenuItem ("Assets/Build AssetBundles")]
    static void BuildAllAssetBundles ()
        // Assets/AssetBundles is the out put path
        BuildPipeline.BuildAssetBundles ("Assets/AssetBundles");

This script requires the folder Assets/AssetBundles to be present. As you might have guessed, this script should be kept in Assets/Editor folder.

Now create the asset bundle using the menu item Assets->Build AssetBundles

Please see for more information on creating asset bundles.

Downloading the asset bundle

Use the following code snippet to download the asset bundle and then to load the scene from it
string ASSET_URL = "your asset url";

var download = WWW.LoadFromCacheOrDownload(ASSET_URL, 0);

yield return download;

if (download.error != null) {
     Debug.LogError("Error in downloading the asset bundles : " + download.error); 
    yield break;

AssetBundle bundle = download.assetBundle;

Application.LoadLevel ("myscene");


  1. I've loaded the scene but I want to make it Unload(false) after Application.LoadLevel ("myscene"); then how can I achieve it..?

  2. Hi There,

    Great post. Well though out. This piece reminds me when I was starting out Downloading asset bundles and loading scene from it with Unity 5.x after graduating from college.

    I am working LDPC encoding and decoding for mini project work. With my effort i have completed LDPC encoding but struggling with LDPC decoding. I need to complete this project within short period so please help me.

    I don`t know how to start decoding algorithm in C language but i do have algorithm. So, can anyone help me in writing C language for decoding procedure.

    Thank you very much and will look for more postings from you.

    Thank you,