Search Unity

Missing Asset Bundle tutorial ?

Discussion in 'Community Learning & Teaching' started by Peter Suwara, Jun 29, 2015.

  1. Peter Suwara

    Peter Suwara

    Joined:
    Apr 16, 2015
    Posts:
    19
  2. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    There were some issues with the content of this video that we would like to address.

    We will be replacing this this a new lesson soon.
     
  3. SubZeroGaming

    SubZeroGaming

    Joined:
    Mar 4, 2013
    Posts:
    1,008
    Hey there,

    I've been working with the new Unity5 asset bundling system for about a month now. Do you have specific questions? The manual on asset bundle has some pretty solid code examples
     
  4. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    We are preparing to describe a high level api and packaged Asset Bundle Manager that can be added into your project to make using Asset Bundles far far easier to use. Until then, the manual and people in the community who know the low level api will be great (and won't change!), but - we will be releasing some additions to the workflow pipeline to improve the speed of iteration.
     
  5. Peter Suwara

    Peter Suwara

    Joined:
    Apr 16, 2015
    Posts:
    19
    Hi there Adam,

    Thanks for replying. We have a working system so far, however I am running into some major issues with caching when asset bundles are loaded as dependencies.

    1. Tested URL LoadFromCacheOrDownload independently and we are getting a positive on IsVersionCached with the asset name.

    2. Test URL as part of a asynchronous download that includes dependencies and we are getting a negative on IsVersionCached of the exact same asset.

    Not sure if its something I am doing, or an issues with AssetBundles being downloaded simultaneously being an issue.

    Regards,
     
  6. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    How are you using the manifest?
     
  7. Peter Suwara

    Peter Suwara

    Joined:
    Apr 16, 2015
    Posts:
    19
    Yes, using the manifest asset bundle, code is based on the AssetBundleManager found in the forums.

    I have also tested some basic loading/unloading functionality of the assetbundles and we are getting some very strange results.

    See below.

    Hi all,

    I am looking for some urgent advice/help regarding asset bundle LoadFromCacheOrDownload.
    UnloadAssetBundle is called on a button click in the UI.
    loadedAssetBundle is a member variable of class that has the functions.

    The following are the steps I take :

    1. LoadFromCacheOrDownload(URL, 0) <- Get a WWW download with assetbundle from the web.
    2. The above is successfull the first time. I check the IsVersionCached -> Returns TRUE.
    3. Call Unload(false) on the asset bundle then destroy the object.
    4. Try LoadFromCacheOrDownload(URL, 0) again with the same asset bundle.
    5. Get the error -> Cannot load cached AssetBundle. A file of the same name is already loaded from another AssetBundle.

    See code below :
    Code (CSharp):
    1.  
    2. private AssetBundle loadedAssetBundle;
    3. public IEnumerator DownloadAtURL(string assetName, string URL)
    4.     {
    5.  
    6.         Debug.Log("PRE ASSET CACHED = " + Caching.IsVersionCached(assetName, 0));
    7.         Debug.Log("Downloading using -> WWW.LoadFromCacheOrDownLoad");
    8.  
    9.         var www = WWW.LoadFromCacheOrDownload(URL, 0);
    10.         yield return www;
    11.         if(!string.IsNullOrEmpty(www.error))
    12.         {
    13.             Debug.Log(www.error);
    14.             yield return null;
    15.         }
    16.  
    17.         Debug.Log("Finished downloading assetbundle");
    18.         Debug.Log("POST ASSET CACHED = " + Caching.IsVersionCached(assetName, 0));
    19.  
    20.         loadedAssetBundle = www.assetBundle;
    21.     }
    22.  
    23.     public void LoadAssetBundle()
    24.     {
    25.         Debug.Log("Loading all assets for bundle " + loadedAssetBundle.name);
    26.         loadedAssetBundle.LoadAllAssets();
    27.     }
    28.  
    29.     public void UnloadAssetBundle()
    30.     {
    31.         Debug.Log("Unloading asset bundle " + loadedAssetBundle.name);
    32.         loadedAssetBundle.Unload(true);
    33.         Destroy(loadedAssetBundle);
    34.     }
    See output below :
    Code (CSharp):
    1. Download Asset
    2.  
    3. POST : https://55AE.playfabapi.com/Client/GetContentDownloadUrl
    4.  
    5. Get content download URL for asset : 1/Windows/Windows result : https://cdn.playfab.com/55ae/etc/1/Windows/Windows?Expires=1438065963&Signature=oJa3DBfiDyRyE2hHix~Wpm1VqLrfoBzLTvlbTlf2RjPGtcwVAJj1y6ms9gp102GLAd7FAT2d-VCpSFKRAXLUPD04tor4j7znLl7EWQqi6TgEyBeLwBp3XY8D69S8gD4EJFH3V54hUVNZmk0nRCKBp4pJqnph4y4-DcChuCiIx0U_&Key-Pair-Id=APKAIOVJ4VBNZZU4TTQA
    6.  
    7. Downloading 1/Windows/Windows from https://cdn.playfab.com/55ae/etc/1/Windows/Windows?Expires=1438065963&Signature=oJa3DBfiDyRyE2hHix~Wpm1VqLrfoBzLTvlbTlf2RjPGtcwVAJj1y6ms9gp102GLAd7FAT2d-VCpSFKRAXLUPD04tor4j7znLl7EWQqi6TgEyBeLwBp3XY8D69S8gD4EJFH3V54hUVNZmk0nRCKBp4pJqnph4y4-DcChuCiIx0U_&Key-Pair-Id=APKAIOVJ4VBNZZU4TTQA
    8.  
    9. PRE ASSET CACHED = False
    10. Downloading using -> WWW.LoadFromCacheOrDownLoad
    11. starting www download: https://cdn.playfab.com/55ae/etc/1/Windows/Windows?Expires=1438065963&Signature=oJa3DBfiDyRyE2hHix~Wpm1VqLrfoBzLTvlbTlf2RjPGtcwVAJj1y6ms9gp102GLAd7FAT2d-VCpSFKRAXLUPD04tor4j7znLl7EWQqi6TgEyBeLwBp3XY8D69S8gD4EJFH3V54hUVNZmk0nRCKBp4pJqnph4y4-DcChuCiIx0U_&Key-Pair-Id=APKAIOVJ4VBNZZU4TTQA
    12. https://cdn.playfab.com/55ae/etc/1/Windows/Windows?Expires=1438065963&Signature=oJa3DBfiDyRyE2hHix~Wpm1VqLrfoBzLTvlbTlf2RjPGtcwVAJj1y6ms9gp102GLAd7FAT2d-VCpSFKRAXLUPD04tor4j7znLl7EWQqi6TgEyBeLwBp3XY8D69S8gD4EJFH3V54hUVNZmk0nRCKBp4pJqnph4y4-DcChuCiIx0U_&Key-Pair-Id=APKAIOVJ4VBNZZU4TTQA cached to C:/Users/Peter/AppData/LocalLow/Unity/WebPlayer/Cache/InfinityPlusTwo_puzzleverse/26d9c28d789c254f71ea99a3463b99a7ccc2f4fa
    13. ----- Total AssetImport time: 0.065631s, AssetImport time: 0.000000s, Asset hashing: 0.000000s [0 B, 0.000000 mb/s]
    14.  
    15. loading from cache: https://cdn.playfab.com/55ae/etc/1/Windows/Windows?Expires=1438065963&Signature=oJa3DBfiDyRyE2hHix~Wpm1VqLrfoBzLTvlbTlf2RjPGtcwVAJj1y6ms9gp102GLAd7FAT2d-VCpSFKRAXLUPD04tor4j7znLl7EWQqi6TgEyBeLwBp3XY8D69S8gD4EJFH3V54hUVNZmk0nRCKBp4pJqnph4y4-DcChuCiIx0U_&Key-Pair-Id=APKAIOVJ4VBNZZU4TTQA
    16. Finished downloading assetbundle
    17. POST ASSET CACHED = True
    18. Unloading asset bundle
    19.  
    20. Download Asset
    21.  
    22. POST : https://55AE.playfabapi.com/Client/GetContentDownloadUrl
    23.  
    24. Get content download URL for asset : 1/Windows/Windows result : https://cdn.playfab.com/55ae/etc/1/Windows/Windows?Expires=1438065979&Signature=eLuGatsAj0-yGDjltOWYIQjBf~4oNtGFlvOcXhacjt0InZjLotfyWPAHAWW64j3UH06sTYfeC9OGmmOjTD~WkkYSLgu5qpLtad6e~DF-cYj3jiK~fblZMEKsTAqhlb3m8~ZnaHqfsFS9~PGjoipUTNHvMy0Yh0JKYwwpa~N3B0Y_&Key-Pair-Id=APKAIOVJ4VBNZZU4TTQA
    25.  
    26. Downloading 1/Windows/Windows from https://cdn.playfab.com/55ae/etc/1/Windows/Windows?Expires=1438065979&Signature=eLuGatsAj0-yGDjltOWYIQjBf~4oNtGFlvOcXhacjt0InZjLotfyWPAHAWW64j3UH06sTYfeC9OGmmOjTD~WkkYSLgu5qpLtad6e~DF-cYj3jiK~fblZMEKsTAqhlb3m8~ZnaHqfsFS9~PGjoipUTNHvMy0Yh0JKYwwpa~N3B0Y_&Key-Pair-Id=APKAIOVJ4VBNZZU4TTQA
    27. PRE ASSET CACHED = True
    28. Downloading using -> WWW.LoadFromCacheOrDownLoad
    29.  
    30. You are trying to load data from a www stream which had the following error when downloading.
    31. Cannot load cached AssetBundle. A file of the same name is already loaded from another AssetBundle.
    32. UnityEngine.WWW:get_assetBundle()
    33.  
    34. [C:/buildslave/unity/build/Runtime/Misc/WWWCached.cpp line 265]
    35. (Filename: Assets/sdk/scripts/TestBedController_Dev.cs Line: 357)
    36.  
    37. WWWCached data can only be accessed using the assetBundle property!
    38. WWWCached data can only be accessed using the assetBundle property!
    39. WWWCached data can only be accessed using the assetBundle property!
    40. WWWCached data can only be accessed using the assetBundle property!
    41. You are trying to load data from a www stream which had the following error when downloading.
    42.  
    43. Cannot load cached AssetBundle. A file of the same name is already loaded from another AssetBundle.
    44. WWWCached data can only be accessed using the assetBundle property!
    45. WWWCached data can only be accessed using the assetBundle property!
    46. WWWCached data can only be accessed using the assetBundle property!
    47.  
    48. Cannot load cached AssetBundle. A file of the same name is already loaded from another AssetBundle.
    49.  
    50. Finished downloading assetbundle
    51.  
    52. POST ASSET CACHED = True
    53. You are trying to load data from a www stream which had the following error when downloading.
    54. Cannot load cached AssetBundle. A file of the same name is already loaded from another AssetBundle.
    55.  

    Any ideas why UNLOAD is not working ?! Seems like a bug in unity, not sure what else I can do here.
    Would be most appreciated and thanks in advance.
     
    Last edited: Jul 29, 2015
  8. Deleted User

    Deleted User

    Guest

    Seems a bug to me, could you please file a bug and post the bug id here? Then I can have a look.
     
  9. Peter Suwara

    Peter Suwara

    Joined:
    Apr 16, 2015
    Posts:
    19
    Thanks Vincent, here it is : (Case 715850)

    Also, when I switch back to using Hash's instead of a version number in LoadFromCacheOrDownload it works.

    I've got some major adaptations to you work (which is excellent by the way), that I would be been to discuss in more detail.
     
    Last edited: Jul 29, 2015
  10. chechoggomez

    chechoggomez

    Unity Technologies

    Joined:
    Feb 25, 2013
    Posts:
    91
    I think you are starting the coroutine DownloadAtURL twice for the same assetbundle
     
  11. futureflyit

    futureflyit

    Joined:
    Feb 10, 2015
    Posts:
    6
  12. Peter Suwara

    Peter Suwara

    Joined:
    Apr 16, 2015
    Posts:
    19
    Still nothing from anyone at Unity about this bug. Can someone please update me on this issue, we are discussing dropping AssetBundle support completely.

    It's been over three weeks and no response from Unity regarding this issue.
     
  13. futureflyit

    futureflyit

    Joined:
    Feb 10, 2015
    Posts:
    6
    We are subscribed to premium support, and the support engineer who I was talking with earlier commented there was no project attached with Case 715850 to reproduce your bug, Peter. Perhaps if you submitted one with your bug as well the issue might get a lift in priority at Unity?
     
    Peter Suwara likes this.
  14. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664