Search Unity

Problem with BuildPipeline.BuildAssetBundle

Discussion in 'Scripting' started by Glabrezu, Oct 23, 2014.

  1. Glabrezu

    Glabrezu

    Joined:
    Aug 30, 2014
    Posts:
    24
    Hi.

    I have an assetBundle created by somebody else, it's in unity3d format.

    I load it up using this code:
    Code (csharp):
    1.  
    2.     AssetBundle test = AssetBundle.CreateFromFile("misc_troll_head.unity3d");
    3.  
    4.     Debug.Log("MainAsset's name: "+test.mainAsset.name);
    5.  
    6.     Object[] assets = test.LoadAll();
    7.     Debug.Log("Found "+assets.Length+" assets inside the bundle. Listing:");
    8.     for (int i = 0; i < assets.Length; i++)
    9.        Debug.Log (i+" : "+assets[i].name);
    10.  
    Everything loads fine, here's the debug log:



    Now I want to repackage it again.

    I do this:

    Code (csharp):
    1. BuildPipeline.BuildAssetBundle( test.mainAsset, assets, "copy/misc_troll_head.unity3d", BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.WebPlayer);
    And the file I get is bad. It contains the mainAsset, but it doesn't contain the array of assets.
    If I load it up with my first piece of code, here's what I get in debug:


    The file is roughly the same size, so the assets must be in there, but they're not loading. Why?