Search Unity

Don't make BuildPipeline.BuildAssetBundle obsolete.

Discussion in 'General Discussion' started by techmage, Mar 26, 2015.

  1. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,068
    I used a workflow before where, I would have a directory of prefabs, and I would make each prefab it's own separate prefab. BuildPipeline.BuildAssetBundle made this easy as I could iterate through directory, grab each prefab, and build an AssetBundle with it's filename as the name of the prefab.

    Now with the new Unity5 AssetBundle system it seems the proper way is to, iterate through the directory of prefabs, apply an AssetBundle tag to each prefab, call BuildPipeline.BuildAssetBundles, then remove all the tags afterwards. So that my AssetBundle tag list doesn't have a few hundred tags in it. Seems a lot more difficult and like it was a system conceived under the notion that a person will put a lot of assets into one asset bundle, not a single asset.

    Which is a thing, perhaps I'm not using AssetBundles as how they were conceived, it seems you assume dozens of assets will be in a bundle, not just one, and the user makes hundreds of asset bundles. But, it works just fine this way I am using it, and there are many use cases where how I do it is really ideal. What if your game had dozens of different objects to load in and you don't want the user to have to redownload a massive asset bundle to just add one object?
     
  2. Redtail87

    Redtail87

    Joined:
    Jul 17, 2013
    Posts:
    77
    I second this, I have a system set up like this as well. For now I am trying to set it up the way you describe, how are you setting the asset bundle through code?

    *Edit - Found out you can do it with AssetBundleBuild like this:

    Code (CSharp):
    1.         AssetBundleBuild[] build = new AssetBundleBuild[1];
    2.         build[0] = new AssetBundleBuild();
    3.         build[0].assetBundleName = "name";
    4.         build[0].assetNames = new string[1] { "Assets/object.prefab" };
    5.         BuildPipeline.BuildAssetBundles("Assets/", build, options, targetPlatform);
    Now to see if I can do it without the extra bundle and manifest files, they are completely unneeded for my case...
     
    Last edited: Mar 31, 2015
  3. kascope_dmarfurt

    kascope_dmarfurt

    Joined:
    Oct 9, 2014
    Posts:
    3
    Hi guys, sorry to resurrect an old thread but you both described my exact situation and I'm wondering if you've come up with any workarounds or other solutions.

    I'm upgrading a project from 4.6 to 5.4 and the assetbundle workflow is supremely outdated. I used the snippet that Mike posted above, and that fixed the building portion, but now my loading is broken. I think I need to re-write my loading methods, but I'm not sure what to do with all the manifest files I'm now generating. Any help would be appreciated.
     
  4. Lockethane

    Lockethane

    Joined:
    Sep 15, 2013
    Posts:
    114
    The manifest files are for when it's building, you don't have to use them at all for loading. Also you can try using the new inspector, https://bitbucket.org/Unity-Technologies/assetbundles-browser/overview to see if the bundle hierarchy is different than you expect it to be.
     
  5. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    12,060
    Is this step necessary? I can see why having hundreds of tags is a pain when you're doing things by hand, but if it's an automated system then what's the issue? Let the computer do what computers do well, which is to perform repetitive tasks on large sets of data.
     
    Kiwasi likes this.
  6. ricna-net

    ricna-net

    Joined:
    Mar 14, 2013
    Posts:
    26
    I can't understand these documentations. Does not make sense!!!

    Someone to help me to understand this annoying:

    From the official documentation about Asset Bundles, we get the information to use the BuildPipeline.BuildAssetBundle
    https://docs.unity3d.com/2017.2/Documentation/ScriptReference/AssetBundle.html

    Here the screenshot from now (20107-09-02)


    So we should consider using the BuildPipeline.BuildAssetBundle, right? They are saying: Use it!

    Then we go to see the documentation about the BuildPipeline.BuildAssetBundle, to use as well...
    But, wait... Something strange here. The same method which they said to you use is OBSOLETE!?

    https://docs.unity3d.com/ScriptReference/BuildPipeline.BuildAssetBundle.html




    Please, Unity... Fix this shame and tell us in details how to use the new method. At least remove this sentence:

    "AssetBundles let you stream additional assets via the WWW class and instantiate them at runtime. AssetBundles are created via BuildPipeline.BuildAssetBundle."

    It's not true or you are considering obsolete methods the best and the only choice? I'm confused...

    Thanks!
     
  7. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    4,129
    Can't you use BuildPipeline.BuildAssetBundles?

    The new API seems to provide the ability to specify the bundle content like in the obsolete methods.
    Code (CSharp):
    1. AssetBundleBuild[] bundles = new AssetBundleBuild[]
    2. {
    3.     new AssetBundleBuild()
    4.     {
    5.         assetBundleName = "prefabs",
    6.         assetNames = new string[]
    7.         {
    8.             "Assets/prefabs/human.prefab",
    9.             "Assets/prefabs/robot.prefab",
    10.         }
    11.     }
    12. };
    13.  
    14. BuildPipeline.BuildAssetBundles("output/bundles", bundles, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.StandaloneWindows64);
    PS: BTW, 2017.2 beta issues are probably better suited to be posted in the beta forum.
     
    ricna-net likes this.
  8. ricna-net

    ricna-net

    Joined:
    Mar 14, 2013
    Posts:
    26
    Yes, seems working after a big error in console.
    And about the beta... The current stable version also has this issue, in fact, this method appears as obsolete since the Unity 5.5 (https://docs.unity3d.com/550/Documentation/ScriptReference/BuildPipeline.BuildAssetBundle.html)!
    But the documentation still saying to use this method until today... :/
    They need to fix it and introduce a better documentation about AssetBundle... It's a shame.
     
  9. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    12,060
    Have you done a bug report about the appropriate documentation page?
     
  10. Norahan

    Norahan

    Joined:
    Oct 18, 2017
    Posts:
    1
    Excuse me... but did you say this code works correctly?
    I get the warning and it says that no asset bundle created with this build ...
     
    ricna-net likes this.
  11. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,021
    Sorry for the late bump but why was BuildAssetBundle made obsolete?? The new system is so much clumsier to work with!