AssetBundle loads but can't retrieve the created prefab

Hi there,

Here is the thing : I want to load Assets in my scene A, then go to my scene B and use the loaded assets there. Looks simple!

Scene A:

WWW request = WWW.LoadFromCacheOrDownload(url, 0);

        while(!request.isDone)
        {
            Debug.Log(request.progress);
            yield return null;
        }

        if (request.error == null)
        {
            ABundle = request.assetBundle;
            var myAsset =  ABundle.LoadAsset("Questions");
             Debug.Log(myAsset.name);
}

Here the outputs shows > Questions
Which is great. Then in my scene B :

var prefabQuestions = Resources.Load("Questions");
GameObject go = (GameObject) Instantiate(prefabQuestions);

I have an error: it says prefabQuestions is null . I guess the path is wrong, but I can’t find the path to the prefab I created in Scene A, what should I do ?

From what it looks like you are trying to load the asset two times:

  • In scene A, by doing
Abundle.LoadAsset("Questions");

Which loads it from the bundle

  • In scene B by doing
Resources.Load("Questions");

Which loads it from resources.

What you would like to do is either:

  • Load this prefab both times from the bundle (as it is in a bundle) (Probably what you want)
  • Load this prefab in scene A, and store it during scene transition, to be still loaded in scene B
  • Try to store this loaded prefab somewhere outside of scene (but i don’t think this is possibly or easy)