Search Unity

Unity 5 Assetbundle: how to check hash of an assetbundle

Discussion in 'Editor & General Support' started by relsirc, Mar 13, 2015.

  1. relsirc

    relsirc

    Joined:
    Jul 3, 2013
    Posts:
    20
    I'm building an assetbundle via script and I was wondering how I'm going to determine if an assetbundle needs to be rebuilt or not. (Note: I'm using the AssetBundleBuild[] parameter when building the assetbundles, so I'm manually including the assets that needs to be built)

    I was thinking of comparing the hash from the manifest of the assetbundle but I dont know where or which to compare it with or how it will look likein code.

    Anyone have any ideas?
     
  2. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    Hi,

    If you construct you AssetBundleBuild[] parameters the same everytime and use the same output path when building the system will automatically determine which AssetBundles actually needs to be rebuild, you dont have to worry about it. Adding or Removeing assets from an AssetBundle will of course also trigger a rebuild as well as changing the build options.

    So you could simple just rebuild everything as part of your build pipeline and it will be fast if no assets have actually changed and you did not change the content or options for building.

    That said I actually do think it would be cool if you could query the AssetDatabase if any AssetBundles at given path would require rebuilding maybe something like

    Code (CSharp):
    1. AssetDatabase.AssetBundlesNeedRebuildingAtPath(AssetBundleBuild[] builds, string outPath, ref bool[] needsRebuilding);
     
  3. relsirc

    relsirc

    Joined:
    Jul 3, 2013
    Posts:
    20
    Thanks for the reply and clarifications. :)

    I'll have a try at it.
     
  4. HG_SB

    HG_SB

    Joined:
    Dec 9, 2015
    Posts:
    39
    Hi,

    Sorry for opening this up again but is there any plan to add such a function? It would be very helpfull to determine if assetbundles need to be rebuild.

    Best Regards,
    Sebastian