Search Unity

Bundle Manager[Released]

Discussion in 'Assets and Asset Store' started by YinXiaozhou, Jan 8, 2014.

  1. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    1.1.7 is released. Enjoy!
     
  2. ronjart

    ronjart

    Joined:
    May 16, 2013
    Posts:
    101
    Does this work with the unity 5 beta?
     
  3. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    Haven't test it in Unity 5 Beta.
     
  4. russiac_sbck

    russiac_sbck

    Joined:
    Jul 12, 2013
    Posts:
    3
    hi YinXiaozhou.

    i have some problem.

    [unity editor]
    Importing Asset:
    BundleManager/BundleData.txt

    BundleData.txt
    size : 650kb

    importing time...very very long time..(not end..)

    unity version : 4.6.1

    help me plz...T_T
     
  5. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    Sorry, I don't really get your problem.
    What are you trying to import? Package from AssetStore? Or the package exported by yourself? Because the BundleData.txt won't be that big in AssetStore version.

    If the package is exported by yourself, what's the version of Unity you exported.
    And did you try reimport BundleManager from AssetStore?
     
    Last edited: Dec 27, 2014
  6. russiac_sbck

    russiac_sbck

    Joined:
    Jul 12, 2013
    Posts:
    3
    I'm sorry i sent the question too short.

    Specifically, any action that refreshes the unity editor such as changing a source code on unity happens, it always try to import the bundledata.txt file

    It seems like when OnPostprocessAllAssets is called from BMDataWatcher, BundleData is read again.

    This process take time very much (sometimes a day long)
    is reimport process natural?

    If so, is there any way to shorten time for this process?

    the BundleData.TXT file we used has the size of 650kb

    We are using 8 asset bundles we made.
     
  7. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    No, it's not natural.

    BM will only reload bundle datas when you changed the data files(4 *.txt files under BundleManager) of BM manually.
    Edit source code should not cause that.
    Even BM reloaded, it should not take that long.

    Did you write your own OnPostprocessAllAssets method?
    Or is there any error messages when the reimport happens?

    Since I cannot reproduce your problem.
    You can put a break point in BMDataWatcher.OnPostprocessAllAssets to check why it's going to reinit BM, and locate the hot point.
    Or if you can send me a minimal demo that can reproduce this, it will be great.
     
  8. russiac_sbck

    russiac_sbck

    Joined:
    Jul 12, 2013
    Posts:
    3
    After putting a BreakPoint in the OnPostprocessAllAssets of BMDataWatcher OnPostprocessAllAssets we found out that,

    modifying any script files files that have no relations) in the unity editor , it operates like Callstack and eventually OnPostprocessAllAssets is called from BMDataWatcher .

    According to what you said , OnPostprocessAllAssets should be called only when files related with BundleManager was changed.
    but on this moment , if any file or resource is modified OnPostprocessAllAssets is called like the Callstack below.

    //-------------------------------------------------------------------------------------------------------------------------------------------------
    4 . BMDataWatcher.OnPostprocessAllAssets (importedAssets={string[1]}, deletedAssets={string[0]}, movedAssets={string[0]}, movedFromAssetPaths={string[0]})

    3. System.Reflection.MonoMethod.Invoke (obj=(null), invokeAttr=The requested item has been unloaded., binder={System.Reflection.Binder.Default}, parameters={object[4]}, culture=(null))

    2. System.Reflection.MethodBase.Invoke (obj=(null), parameters={object[4]})

    1. UnityEditor.AssetPostprocessingInternal.PostprocessAllAssets (importedAssets={string[1]}, addedAssets={string[0]}, deletedAssets={string[0]}, movedAssets={string[0]}, movedFromPathAssets={string[0]})
    //-------------------------------------------------------------------------------------------------------------------------------------------------

    our PC specification is

    Developing PC : Mac
    Unity Version : 4.6.1
    BundleManager Version : 1.1.8
    -Unity Editor Setting-
    Version Control Mode : Visible Meta Files
    Asset Serialization : Mixed

    Please check one more time. Thank you very much.
     
  9. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    Thank you for your effort. But you may misunderstood what I said.

    OnPostprocessAllAssets will be call on every moment Unity trying to import or move assets.
    But BMDataWatcher.OnPostprocessAllAssets will do nothing if files out of BundleManager reimported.

    Could you do a simpler test for detecting the problem for me? Just comment/remove all code in BMDataWatcher.OnPostprocessAllAssets method. If the reimport slow down still happens, maybe it's not a issue with BundleManager. It may caused by some thing else in your project.
    If problem resolved, then we can be sure that's a problem of Bundle Manager.
     
  10. Filein

    Filein

    Joined:
    Oct 23, 2014
    Posts:
    7
    hi YinXiaozhou.

    I updated BundleManager to 1.1.9.

    When download an assetbundle with parent assetbundle, there is a bug about WWWRequest.requestString.
    It doesn't set the requestString in parent assetbundle. you should check Line 491 in DownloadManager.cs.
     
  11. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    Thank you Filein. This bug can cause trouble when user trying to get automatically download parents bundles.
    The fix will be on store soon.
     
  12. Filein

    Filein

    Joined:
    Oct 23, 2014
    Posts:
    7
    You're welcome. Exactly I'm facing the problem... ;) (I fixed the bug, but I thought you should know that.)
     
  13. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Hey guys, just barely purchased this asset, looks promising.
    I wanted to ask however, once Unity 5 is released, will this asset still have benefits over their new Asset Bundle features that will be found in Unity 5? I'm just getting started with supporting Downloadable Content in our project so want to be informed before I get started. Thanks!
     
  14. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    We discussed this in page two. Past it here for you,

    I haven't tried Unity 5 beta. All my knowledge of Bundle System in Unity 5 comes from this video. Seems the APIs we currently using can also work in Unity 5, which is great.

    Although the new bundle system have some advantages compare to our plugin, but as I can see there's some design problem in it. For example, new bundle system only allow one asset per bundle, this is bad for many kind of game. They don't have a bundle list like us. People still need to write code for build system and take care about bundle targets.

    The 'real' increment build by hash is good(In our plugin we compare the change time of files, working great). And the new runtime API of cache download can avoid some problems in old system.
    We are going to take these advantages from new bundle system, if the APIs is open enough.
     
  15. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Thanks for the response, and sorry to have you repeat the discussion. Asset Bundles have always seemed scary and hardly anyone I've talked to has used them so I'm going to dive in using Bundle Manager and hopefully I can figure it out!
     
  16. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Now that I've played around with Bundle Manager I'm going to have a few question, but I am loving it so far.
    After I Build a Bundle, I'm able to find the outputted files, but I'm noticing that a built bundle such as ABC.assetBundle is only a few KB big. I'm new to Asset Bundles so I'm sure I don't understand, but I thought that an assetBundle file would include the assets that were included in the bundle? For example I have a prefab in the bundle that has a bunch of PNG images, are those not included in the .assetBundle file? If I put just he ABC.assetBundle file on a server and downloaded it during runtime, surely it wouldn't have everything it needs when its only a few KB big. What am I missing here?
     
  17. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    So it appears that you need to manually add any media asset such as PNG files to the bundles? For some reason I thought that if I dragged in a Prefab to a Bundle, that it would automatically add any and all needed files found in the prefab to the bundle. Is this the correct way to do things? Manually adding art assets and such to bundles?

    How do the files I manually add need to be structured so the prefabs in the bundle are able to find them?
     
    Last edited: Feb 11, 2015
  18. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    !!! I finally figured out what is going on. I'm using 2DToolKit for my 2d images. I was using the multiple asset functionality in 2DToolkit which allows you to have the same asset at differnet resolutions, and it creates multiple prefabs on the back end of things. Doing this, and adding a prefab with 2DToolkit sprites to the Bundle Manager, it appears Bundle Manager doesn't know how to handle this setup from 2DToolkit. (Or maybe its Asset Bundles in the end?) If I use 2DToolkit without the multiple asset functionality then Bundle Manager correctly grabs the needed art assets and includes them in the assetBundle. Is there any chance this can be fixed to play well with 2DToolkit?
     
    Last edited: Feb 13, 2015
  19. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    Sorry for no responding for such a long time. I missed the post here until your email last night.

    I tested multi asset sprite of 2DToolkit with BundleManager, by adding a sprite prefab into asset bundle in Bundle Manager. And load it at runtime, which is working fine.

    So can you test multi asset sprite collection again? Or do you have any special needs other than just load sprite from bundle by using multi asset? I'm not quite good at 2DToolkit.

    collectionSettings.PNG spriteBundle.PNG testcode.PNG runtime.PNG
     
  20. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Sorry the 2DToolkit feature I was meaning to say is where you can have an art asset and then a second with the same file name with @2x on the end.

    http://www.unikronsoftware.com/2dtoolkit/doc/2.5/advanced/platform_specific_sprite_collections.html

    Import a second copy of your test image that has the same name as the original and add @2x to the end of the name. In your sprite collection settings area click the "Add platform support", set " Current platform" to 1x and click "Add new platform" and set it to 2x. Then when you click Commit you will be using the setup bundle manager is having trouble with.

    I can send a test scene if you would like but doing the above should show you the issue.
     
  21. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    I tested multi platform sprite. Every thing work fine except the depend assets list dose not connected to the atlas textures. I guess it's because 2DToolkit sprite dose not really referenced them until it's actually used.
    But you can still pack sprites into bundles, and use them in runtime, every platform in the sprite collection will be packed into the bundle. You can switch to any platform you added into the collection.
     
  22. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Ah ok, so I guess I would just need to use code to load up the sprite collection from the bundle that I need rather than having it be automatic.
     
  23. Filein

    Filein

    Joined:
    Oct 23, 2014
    Posts:
    7
    Hi~~ I'm wondering if this is a bug or not...

    I can't click or select a dependency item in AssetBundle on item list. Everyone works fine except me?

    It's annying me to find the dependency item. So I searched the sources.. If it's a bug, can you check "BundleEditorDrawer.cs" Line 213?
     
  24. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    Yeah, It's a bug. And line 213 is exactly the culprit. You can fix this bug by change it to

    boolisCurrentPathSelect = m_CurSelectAsset == guid && m_IsMetaListSelect;

    It's been introduced for a while so maybe a lot of people think it's designed like that. The fix will be in the next version.

    Thanks.
     
    Filein likes this.
  25. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    I've got some fundamental questions that I need answered. I've got my asset bundles loading and working fine via the Editor and am now ready to instead download them from a server before loading them. I'm looking at the WaitDownload method to download my assetBundle from my server, but all the examples in the documentation show just the bundle name being used, there is never a web Url used. I'm confused on how to tell Bundle Manager what the server's URL is to download the assetBundle file. Help please?
     
  26. Lazy

    Lazy

    Joined:
    Oct 5, 2012
    Posts:
    7
    The server's URL is set in settings of BundleManager(Down load url). So in code you just need to use bundle's file name.

    For more information plz read StreamingAtRuntime.PDF and LearningTheInterface.PDF under the folder of BundleManager.
     
  27. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Thanks. Yea I've read over the PDF documents probably 10 times now, it just wasn't clicking for me.

    So if I had multiple assetBundles at one URL location on a server, I would change:
    $(DataPath)/../AssetBundle/$(Platform)
    To something like:
    http://www.myhosting.com/dlcBundles

    Then any .assetBundle files found in the dlcBundles directory on the server can be accessed by just using the bundle name in code correct?
     
  28. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    Yes, that's how it works.
     
  29. argc_argv

    argc_argv

    Joined:
    Dec 14, 2013
    Posts:
    35
    Hi what is the correct way to update the plugin?
    I want to keep my old settings.
    I tried to export settings then copy paste in back into project BundleManager folder.
    Clean my cache then start the game
    But bundle manager gives me a 404 error.
     
  30. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    Screen Shot 2015-03-02 at 11.51.21 AM.png
    You need to keep a copy of this four files. And copy them back after import new package.
    What is 404 error exactly? Can you past the full error message here?
     
  31. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Has anyone been using this plugin on Unity 5? Wondering if I'm ok to migrate a project from 4.6 to 5.
     
  32. argc_argv

    argc_argv

    Joined:
    Dec 14, 2013
    Posts:
    35
    Don't migrate to Unity 5 yet.
    I tried it got some deprecated API call error:

    Unity.Engine.AssetBundle.Load(string) is obsolete
    Please use LoadAsset instead
     
  33. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Thanks for the heads up.
     
  34. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    I have tried Unity 5. There's some error as API changed. I modified them to new API. Then every thing seems working fine. I will push the new version up in a few days.

    If you want a test version, send me a email.
    @argc_argv @rxmarccall
     
  35. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    @YinXiaozhou I'm ok to wait a few days, thank you for doing that!
     
  36. argc_argv

    argc_argv

    Joined:
    Dec 14, 2013
    Posts:
    35
    Thanks man! I'm submitting to App Store soon so I think I will use 4.6.3 for a bit longer.
    Will bundle manager be backwards compatible with 4.6.3?
     
  37. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    It will be compatible with Unity 4.x
     
  38. argc_argv

    argc_argv

    Joined:
    Dec 14, 2013
    Posts:
    35


    this was my 404 error after updating bundle manager.

    UPDATE:

    after this I did the following to fix the error:

    rebuilt any one asset bundle and uploaded new BM.data, BMConfiger.txt, BuildStates.txt, BundleData.txt (yourBundleName).assetBundle

    Then tried the play the game again and it all works.

    QUESTION:
    Why does this happen? Maybe BMDataVersion is not updating or something?
     
    Last edited: Mar 8, 2015
  39. argc_argv

    argc_argv

    Joined:
    Dec 14, 2013
    Posts:
    35
    A problem with loading from the cache when there is no wireless.
    My process is this:
    1. Build app to run on iPad with wireless on. All bundles downloads correctly.
    2. terminate app. turn off wifi.
    3. open app again. bundles load from cache correctly.
    4. restart app a few times, every time bundles are loaded from cache correctly
    Now here is the problem, after some time, or maybe a certain number of restarts. The app can't load from cache anymore. The app doesn't crash or freeze, so it seems that it is stuck in one of the download coroutines. There are no errors in Xcode either.

    To investigate, I put some debug logs and narrowed the problem to this:





    In Xcode when app is running without wifi:


    I think I will try to cache BundleData, BuildStates and BMConfiger manually into plain text files and load them that way. Then I will report back.

    THE FIX:
    I cached my own results then loaded them like this: Remember to set iPhone.NoBackUp to your own caches.
     
    Last edited: Mar 9, 2015
  40. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    To be honest, I don't know what's going on with this. I cannot get the same issue on my PC. T_T
    It's not about BMDataVersion. Must be something wrong with the Url settings. Maybe if you give me a test environment, I can figure it out. But you know, it's not a big problem, you may want just leave it...

    And I just found a better way to update your BM plugin. Don't need copy&past files.
    You can make these data files unchecked, and import everything else. Then it will be fine(at least on my machine).
    Screen Shot 2015-03-09 at 12.33.22 PM.png
     
  41. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    Sorry, I thought you fix this issue a few month ago.

    Your logs only tell us one thing: the DownloadManager is not initialed.
    Seems the initial process get stuck by some WWW request which never success nor fails.
    Can you find a log like "Cannot load BMData from target url. Try load it from cache." ?

    About your fix, what's is iPhone.NoBackUp? I googled this but have no luck.
     
  42. argc_argv

    argc_argv

    Joined:
    Dec 14, 2013
    Posts:
    35
    1. Can I just drag a download Manager into my scene in the editor? I thought the Singleton you have will always automatically instantiate the DownloadManager.
    Yes, I have the log "Cannot load BMData from target url. Try load it from cache."

    2. iPhone.SetNoBackupFlag(filePath);
    iOS need this to prevent generated file from backing up to iCloud. Need this to pass Apple's app store submission review.
    I was also wondering if you have tried bundle manager with and iOS apps? My app was just rejected by Apple today because it failed to pass the iCloud backup rules. I am pretty sure my own cache files are all marked as SetNoBackupFlag.

    See here for more detials:
    http://docs.unity3d.com/Manual/iphone-Downloadable-Content.html

    Quote from this page:
    The downloaded asset bundle files are stored in the Library folder of the iOS application sandbox and have the No Backup flag set on them. This means the OS won’t delete these files accidentally and these files won’t be backed up to iCloud. It is good idea to keep the cache size limitlow, to prevent your app from grabbing all the device’s disk space.

    If you need to choose exactly where the AssetBundle file is stored, you can use a standard WWW download (ie, just use the constructor instead of LoadFromCacheOrDownload) and then save the downloaded data on disk using the .NET file API. You can save required files to theApplication.temporaryCachePath folder (stored in Library/Caches which is regularly “cleaned out” by the OS) or theApplication.persistentDataPath folder (stored in Documents which is not cleaned out by the OS). You should set the No Backup flag on these files with iOS.Device.SetNoBackupFlag to prevent them being backed up to iCloud.

    Note: If you don’t set the No Backup flag, your app may be rejected when you submit it to the App Store.

    Some relevant Apple links:

    https://developer.apple.com/icloud/documentation/data-storage/index.html

    https://developer.apple.com/library...de/FileSystemOverview/FileSystemOverview.html
     
    Last edited: Mar 10, 2015
  43. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    1.DownloadManager need BM.data bundle to init itself, in your case WWW.LoadFromCacheOrDownload is not work as expected. Creating DownloadManager object manually won't help on that.
    If you modify the way DownloadManager get the BM.data, by save it to your local disk, it may work. I can give you a modified version for test in a few days.

    2.In BM we only use Unity's cache system, not file operation API is used. And in that doc you mentioned, Unity promise all the cached datas is marked with NoBackup. So could be somewhere else used files without NoBackup.
    We released an app with BM. I'm not the IOS programer in our group, but I never hear we got problem on NoBackup from him.
     
  44. argc_argv

    argc_argv

    Joined:
    Dec 14, 2013
    Posts:
    35
    1. I modified it my self to make it work for now.

    2. I am going to submit a version to Apple without any asset bundle features and see if the app is still rejected, so hopefully I can isolate the problem. But yeah I went through all your source code and everything seems to be working correctly

    Thanks for the help!
     
  45. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
  46. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    About Unity 5

    Many questions about new Asset Bundle system Unity 5. So I write my opinion here:
    It's glad to see that Unity finally trying to face this mess.
    BM have lot of common with this new system, GUI only management, incremental building, etc. But we have some design differences on how to deal with bundles.

    1.GUI design. We think streaming solution is a big deal for Games. So we give BM a whole window to deal with it. Compare to Unity's small widgets, BM will be more convenient if you have too many bundles.

    2.Bundle dependency design. We and Unity both agree hard coding dependency management is torment for developers. So in the new system, Unity want manage bundle dependencies automatically. But we think developers need full control on the dependencies.
    Sometimes we just don't want bundle A depend on bundle B, even they have same x asset. Because bundle A or B may have some other assets much bigger than x.

    As a plugin created more one year, we have some small functions Unity don't have.
    Also new system have functions we don't have, like bundle variant. So you should be careful to decide use BM or New Bundle System.

    For now BM will keep working on legacy bundle system. Since the new bundle API is not open enough, that we cannot edit the bundle content. And there's no way to manage dependencies manually. If the new system API keep evolve, once it's ready, we will move to the new API.
     
  47. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    @YinXiaozhou
    Thanks for the update and letting us know!
     
  48. argc_argv

    argc_argv

    Joined:
    Dec 14, 2013
    Posts:
    35
    Can I request a feature? ;)

    In the editor bundle manager window, can we have folders? I have some 70+ bundles that I want to organize better.
     
  49. YinXiaozhou

    YinXiaozhou

    Joined:
    Oct 19, 2013
    Posts:
    133
    If you mean put the bundle files into subfolder. It's already supported by adding relative path into bundle name. For instance, have bundle A, we can move A into subfolder by change A's name to subfolder/A.
    In runtime, you can download this bundle by,
    DownloadManager.Instance.StartDownload("subfolder/A.assetbundle");

    Or you only want make subfolders in the bundle list for archive. It's hard to design and implement:eek:, since we already have a tree structure for bundle dependencies. But you can archive your bundles by give them prefix names, since the bundle list is sort by name.
     
  50. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    I'm still having a hard time using Bundle Manager for my situation, some help from those that are using it would be appreciated.

    My project has add on DLC packs that only need to be downloaded once and then loaded locally from the device from then forward. I only want the user to have to download the assetBundle 1 time. I understand how to make my asset bundles using Bundle Manager, I'm just trying to understand which runtime APIs I should use to download the asset bundle and then access the assets inside.

    I read previously in this thread to not use "LoadFromCacheOrDownload" because then you lose the benefit of what bundle manager gives. So I'm trying to use the example code in the "StreamingAtRuntime.pdf".

    My questions then are: is "WaitDownload" only used to download the assetBundle the first time, or is it used always and it automatically checks if the asset bundle needs to be downloaded or if its already cached locally? If it handles both cases, how can we know which case it is dealing with at the moment? I ask because I want to be able to have a download progress bar if its downloading from a server.

    I think part of my confusion is that I need a solution that downloads the entire .assetBundle file all at once and stores it locally, I don't want to stream it piece by piece from the server as things are needed. Should I look at using Unity's APIs if I'm wanting to do things that way?
     
    Last edited: Mar 14, 2015