Assetbundle gameobjects loosing script reference

Im creating scene asset bundles via BuildStreamedSceneAssetBundle, but when I load the assetbundle in the editor, it throws out errors about referenced script is missing.

I created the asset bundle like this

Debug.Log(BuildPipeline.BuildStreamedSceneAssetBundle(new string[] { sceneName }, bundleLoc + sceneName  + ".unity3d", BuildTarget.StandaloneWindows));

And I am loading it like this

string sceneUrl = "file:://C:/AssetBundles/" + sceneName + ".unity3d"; 
WWW www = WWW.LoadFromCacheOrDownload(sceneUrl, 1); yield return www;

if (www.error != null)
{
    Debug.LogError(www.error);
    Debug.Log(sceneUrl);
}
else
{
    Debug.Log("Done");
    sceneAB = www.assetBundle;
}
 
Application.LoadLevel(sceneName);

It loads it up but most of the scripts seem to be missing. Anyone have problems with this?

Did you ever get a resolution on this? I’m experiencing the same thing, but not in all asset bundles.

Not entirely. I am uncertain how it all works but I guessed that if a script isn’t referenced in your assets that you create the pkg/exe with, it doesn’t include it. What I did was wrote a dependency parser that looked for all *.cs and created a hashset with those names, then created an object and added all the script components to that object, added that “allScript” prefab to a scene that I included in the build settings. That scene is never used but causes the export to include all those scripts (I believe).

Other areas I have found it that while testing i would get bad/old bundles. I delete the asset bundles in the users directory, in App data/local/unity I believe.

Hope some of that helps you. We have to the standalone windows to work with its asset bundles, and the unityplayer to work with pc but not android. In our case it looses SOME textures, not all.

Oh, forgot my biggest problem was when I was creating the asset bundles the script would sometimes fail as was testing code out. This was in the middle of the push/pop flow and what would happen is that unity would maintain the push list so when I went to run again it would produce empty asset bundles.

How can we solve this problem on Android or IOS platform? Our project need it, but this problem already puzzle us much long time.