Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Building Asset Bundles always forces reimport

Discussion in 'Scripting' started by sirrus, Apr 13, 2017.

  1. sirrus

    sirrus

    Joined:
    Jun 10, 2012
    Posts:
    250
    We have a project we are testing in Unity v5.6.0f3 which builds a large number of assetbundles.

    Up to this point, this project has been able to build assetbundles for individual assets efficiently and quickly using the (now obsolete) BuildPipeline.BuildAssetBundle() function. Now we are trying to use the 5.x version with BuildAssetBundles() however each time we do this, it forces a reimport of sorts:

    • "Hold on: Determining assets that need to be reimported for target platform"
    • "Hold on: Calcuating asset hashes"

    This happens even if only a single assetbundle is built.

    This would render the entire project useless because of the time it takes to perform these calcuations. Is this a bug? A single assetbundle shouldn't take over a minute to build.

    This happens whether we use the SetAssetbundleNameandVariant API *or* build the assetbundle(s) using a Build Map.

    FWIW we use the 5.x assetbundle system in a separate project in v5.3.7 w/o problems.

    I will save my gripe about losing the BuildAssetBundle() capability for another day ;)

    Thanks for any assistance.
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    Where are you losing BuildAssetBundle?

    As far as reimport, I'm using Unity's asset bundle manager from the asset store. It might be a little outdated, but it includes a menu option to build asset bundles and it doesn't trigger a reimport. Usually it works pretty quickly depending on what I'm bundling and how much I'm bundling. I have noticed every so often it takes a little longer the first time I build after opening a project fresh for the day, but it's usually a short delay, so I don't notice it much.
     
  3. sirrus

    sirrus

    Joined:
    Jun 10, 2012
    Posts:
    250
    Yeesh.. I may be losing my mind. I swore in a beta test or something of 5.6, the project wouldn't compile because BuildAssetBundle() was rendered obsolete. It looks like, though marked as obsolete, it still works in the final version so I happily stand corrected on that point (for now). I hope Unity opts to keep supporting it.

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

    In terms of the reimport, it looks as though NOT specifying a build target in BuildAssetBundles() causes the reimport. I assumed the build target would default to the current platform but apparently it doesnt properly build them at all (or at least does so after a reimport). Either way, specifying the build target seems to work as intended so that's my bad as well. Thanks.
     
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    Ah, that's good to know. I know unity uses this

    Code (CSharp):
    1. BuildPipeline.BuildAssetBundles (outputPath, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
    in their build script that came with the asset, so that's probably why I never noticed a reimport. Good info to have in the future though in case that asset ever has issues for me and they don't update it.
     
    twobob likes this.
  5. wangjiangang

    wangjiangang

    Joined:
    May 5, 2015
    Posts:
    15
    hi, have you solved the problem? i got the same problem~ ~
     
  6. sirrus

    sirrus

    Joined:
    Jun 10, 2012
    Posts:
    250
    We are no longer using the BuildAssetBundles API but the automatic reimport was happening because we weren't specifying a build target in the function call.
     
  7. Wothanar

    Wothanar

    Joined:
    Sep 2, 2016
    Posts:
    122
    this happend to me with the assets bundle browser... i never switched the plataform and its on standalone windows but seems that every time when i want to build an assets bundle its takes too long start to doing that reimporting of plataform when it should not do it ... its FRUSTRATING AND DAMN ITS TAKE LONG TIME TO WORK LIKE THIS ... and all of this im using assets bundle coz unity limit us 4gb texture data :(
     
  8. IOZO

    IOZO

    Joined:
    Jun 26, 2010
    Posts:
    55
    same for me. It's very frustrating
     
  9. todoned

    todoned

    Joined:
    Apr 10, 2017
    Posts:
    2
    same for me... spending 10 minutes or more to build a single asset bundle due to re-import, calculating asset hashes, downloading from the cache server, etc... all for a single 20MB material to be put into a bundle containing only 2 assets... And yes, all this because I hit the 4GB limit. My build now takes many many hours to complete, for just 500 materials (each into its own bundle). Need a solution.

    I *am* specifying the build target, and this still occurs...

    BuildPipeline.BuildAssetBundles(p, buildMap,
    BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows);
     
  10. sirrus

    sirrus

    Joined:
    Jun 10, 2012
    Posts:
    250
    I think this may happen when your project is targeted for something other than what you are targeting for BuildAssetBundles.

    For example, if your project platform is set for Windows Standalone but you start building assetbundles targeted for WebGL, the Editor will have to package those assets for WebGL and then re-import them and recalculate hashes back for your project (i.e, Windows).
     
  11. AsaBattle

    AsaBattle

    Joined:
    Jan 3, 2017
    Posts:
    7
    This same thing seems to happen to me, but for no apparent reason. It will happen what seems to be completely randomly every 5 to 20 builds. Sometimes 2 or 3 times in a row! I'm not changing or re-importing any assets at all, or changing any build settings. Nor am I using any special buildassetbundles related stuff. Does anybody know why this is/could be happening? Any help would be very greatly appreciated!
     
  12. Orion

    Orion

    Joined:
    Mar 31, 2008
    Posts:
    261
    *Bump* Same problem here. I'm using
    Code (CSharp):
    1. BuildAssetBundles (path, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
    Worst of all, in my case it also triggers expensive "OnPostprocessAllAssets" calls... :( Help?
     
  13. Ender_7

    Ender_7

    Joined:
    Nov 22, 2015
    Posts:
    11
    Has anyone found any solutions to this?
    My team is on unity 2017.4.22 and one of our machines can build the asset bundles just fine, whereas every other machine needs to reimport all assets and rebuild all asset bundles.

    Edit: It turns out that the asset bundle browser plugin thinks there is a difference between windowsStandalone and WindowsStandalone 64bit asset bundles. We resolved our issue by forcing the bundle build target to be the editors current build target.
     
    Last edited: Jun 20, 2019
  14. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    It seems in new asset bundle system there's no option to build single asset bundle with dependencies. I was thinking of separate machine for building bundles when saw this thread. Seems no solution here too...
     
  15. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    I have same issue.
     
  16. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Same issue. :(

    Oh wait, it fixed itself when i set to Windows64.

    Weird. o_O
     
    Last edited: May 1, 2021