Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

The AssetBundle Manager Tutorial Q&A

Discussion in 'Community Learning & Teaching' started by Adam-Buckner, Sep 11, 2015.

  1. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,670
    This is the official Q&A thread for the AssetBundle Manager Tutorial.

    AssetBundles allow on demand streaming and loading of Assets from a local or remote location. With AssetBundles, Assets can be stored remotely and accessed as needed, increasing the flexibility of the project and reducing the initial application size.

    The AssetBundle Manager provides a High-level API for a massively improved workflow compared to manipulating AssetBundles directly with the foundation Low-level API.

    *Please be aware that this is a thread for answering specific questions and issues with the Tutorial, NOT a general AssetBundle support thread.*
    • Please keep questions framed and related to the tutorial.
    • Please use the main support forums or answers for other AssetBundle related questions.
    • Questions will be moved or deleted from this section if they are not considered appropriate.
    The tutorial can be found here.
    The asset package can he found here.
     
    Aenigmaticus and SimonDarksideJ like this.
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,634
    Glad to see this updated after the "incident" :D
    Great stuff @Adam Buckner this info is sorely needed
     
  3. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,670
    There are other high level AssetBundle features we are working on. Don't expect them to jump out and surprise you tomorrow, but there should be more to come.

    I'll update this thread and the tutorial and assets as needed.
     
  4. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,634
    Thread tagged for reference (when my mind wanders :D)
     
  5. Iseebees

    Iseebees

    Joined:
    Jan 4, 2015
    Posts:
    5
    Dear Unity Technologies,

    How do I get the downloaded asset bundle manifest (or it's data) from AssetBundleManager.cs into another script?

    At various places in AssetBundleManager.cs, I've tried to get the all the asset bundle names from m_AssetBundleManifest and save them to a string[], but to no avail. A null reference exception occurs.

    I'm using LoadAssets.cs, but instead of setting each asset bundle name and asset name the inspector, I would like to use GetAssetBundleNames() to iterate through the manifest and instantiate assets according to certain conditions.

    The new tutorial has been a great help, thank you for that. Relief was brought to my brain.
     
  6. Iseebees

    Iseebees

    Joined:
    Jan 4, 2015
    Posts:
    5

    I finally managed to get the asset bundle manifest. In LoadAssets.cs, I used to following code in the Initialize() function to get the manifest from the variable: request:

    myManifest = request.GetAsset<AssetBundleManifest> ();
     
    ZeFirestarter likes this.
  7. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,670
    Ah fantastic. Glad you got it working. There are many people tied up getting ready for, and this week attending, Unite 15 in Boston. Sorry for they delay.
     
    twobob and SimonDarksideJ like this.
  8. Nickolay I

    Nickolay I

    Joined:
    May 26, 2015
    Posts:
    3
    Hi All!
    I am beginner developer on Unity. What stores you can recommend me to put my different scenes bundles?
    For example: I have 6 different game levels, I put it to 6 bundles. Can I use amazon S3 or google cloud platform to place my bundles? What will be easier and faster? Also I want to have CDN access. So users from all the word will have theirs native servers for my assets.
     
  9. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,634
    There are many options for that @Nickolay I. from Azure, AWS and GameSparks.
    Most offer some level of CDN support, although it does cost more obviously.

    Just shop around for the best deal that fits you, just needs to be network accessible storage from the internet.
     
    Nickolay I likes this.
  10. rocket5tim

    rocket5tim

    Joined:
    May 19, 2009
    Posts:
    230
    Is there a way to include baked lightmap data in AssetBundels when loading a scene?
     
    Last edited: Oct 5, 2015
  11. Iseebees

    Iseebees

    Joined:
    Jan 4, 2015
    Posts:
    5
    I went with Amazon S3 to store my asset bundles. Amazon Cloudfront is what I'm using to distribute the content. Cloudfront will take the files from S3 and copy them to servers located throughout the world.

    I just signed up for Amazon Web Services and received 12 months access to those services for free—up until a certain data allowance, afterwhich you pay for the excess data you use.
     
  12. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,106
    Any chance to get an example/ tutorial on doing command line batching for asset bundle generation?

    (would be great to see that tutorial be converted to a 100% handled command line example)
     
  13. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,106
    ok, how about also explaining exactly what is in the 'AssetBundleServer.exe' :D I'm just starting to look over this tutorial and curious... is this something that if I were to create a batchmode project to automate assetbundle generation, this would or may have some dependencies?

    it's like a black box.. hopefully not a Pandora type box :D


    [edit]

    ok, i'm starting to put it together in my mind (ILSpy, thanks :D)

    and this:
    ProcessStartInfo startInfo = ExecuteInternalMono.GetProfileStartInfoForMono(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), "4.0", pathToAssetServer, args, true);

    interesting, I've not worked with asset bundles yet, but need to... the tutorial is complex.
     
    Last edited: Oct 20, 2015
  14. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    302
    I'm trying to integrate Asset Bundles into my existing project, when I choose the "Build Asset Bundles" option I end up getting the error: "
    Building AssetBundle failed because hash collision was detected in the deterministic id generation.
    Conflict happened between Asset "Assets/$root/AssetContent/Volume2/SpriteCollections/Props/V2Props_Collection@2x_1 Data/atlas0 material.mat" and "Assets/$root/AssetContent/Volume2/SpriteCollections/Story2/V2S2_Collection@4x_4 Data/atlas0 material.mat".
    UnityEditor.BuildPipeline:BuildAssetBundles(String, BuildAssetBundleOptions, BuildTarget)
    AssetBundles.BuildScript:BuildAssetBundles() (at Assets/AssetBundleManager/Editor/BuildScript.cs:24)
    AssetBundles.AssetBundlesMenuItems:BuildAssetBundles() (at Assets/AssetBundleManager/Editor/AssetbundlesMenuItems.cs:27)
    "

    Could you help me understand what I'm doing wrong? Does some kind of similar naming of files cause hash collisions?

    I am using 2D Toolkit which has sprite collections, and each of those has a material called "atlas material.mat", it seems like this is causing the issue? (Though they are in different folder
    hierarchies
    ) Will I need to rename these somehow?
     
    Last edited: Oct 21, 2015
  15. Dave-Hampson

    Dave-Hampson

    Unity Technologies

    Joined:
    Jan 2, 2014
    Posts:
    149

    I've dealt with a ticket like this before, and let me share the information I recall:

    • The hash collision is not to do with the filename, it's to do with a field (visible in the YAML if you have text serialisation like this - 4: {fileID: 400030} ). The two filenames however can be used to narrow down the value search to those two files.
    • I think it's fixed in Unity 5.x.
    • I was able to fix it in the case I looked at by changing that 400030 to something else, in the case I looked at I used 490030. I changed every occurrence of 400030 in one of the YAML files to 490030 and the problem resolved itself, but I advised the customer to upgrade to 5.x to solve the issue 'properly'.
     
    twobob and SimonDarksideJ like this.
  16. sunxdc15

    sunxdc15

    Joined:
    Jan 2, 2014
    Posts:
    7
    Hello guys,
    I have a question about clean the duplicated assets in asset bundles. for example
    1. a.png is referenced by b.prefab and c.prefab
    2.b.material is assigned to bundleb and c.material is asssigned to bundlec, a.png is not assigned.
    now the a.png is duplicated in bundleb and bundlec. What I want to do is check the assets in all bundles and found the duplicated asset. but I can't get the all asset in bundles. if I use GetAllAssetNames() or LoadAllAsset(), I only get b.prefab or a.prefab return.
    How should I do?

    Thanks.
     
  17. chayanvinayak

    chayanvinayak

    Joined:
    Jul 11, 2012
    Posts:
    24
    Is there any way to suppress generation of .manifest file while exporting assetbundles?
     
  18. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    481
    How to get the loading progress when loading a scene from AssetBundles?
     
    ZeFirestarter likes this.
  19. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    481
    I have found that lightmaps get stripped in some way. Thus including some baked lightmaps in the starting scene or a simple "blind" baked scene into the build prevents this. This works for me.
     
  20. fokziu

    fokziu

    Joined:
    Apr 10, 2015
    Posts:
    7
    I am facing the same issue and my unity version is 5.2.2f1. The docs say that you calculate hash based on GUID and some other voodoo black magic but I don't think this is a coincidence that whenever I have same names (different paths) of files I get this collision.

    I just did the most simplistic project to test. I have an asset bundle with a variant on it and two different paths. (foo/bar and boo/baz) both contain a file i_hate_unity.txt with different contents.

    GUIDS for those files stored in meta unity generated are different yet the collision occurs. Meta for txt files are so simple that there are no additional information like fileID or something else.

    Therefore I assume that you take filename (not the path) into consideration while generating the hash thus the collision.

    Correct me if I am wrong, but if this is true you would require us to have unique names on all files in the project which in large project that are already in production is almost impossible to fullfill.
     
  21. Anemor2000

    Anemor2000

    Joined:
    Jun 12, 2015
    Posts:
    39
    Question. I am using the tutorial files and all is working perfectly except this :
    The game does not work if phone is offline. It's logical, how can the bundlemanager know what the manifest is if it's offline. But how can I tweak the manager for it to load from cache when no connection is available.

    Since it is a fairly big issue I am sure others must have had problems with it in the past.
    I'm really stuck on this since my game has to be playable offline so thanks for your help.

    Joseph
     
    Last edited: Nov 19, 2015
    ZeFirestarter likes this.
  22. JustinTMG

    JustinTMG

    Joined:
    Sep 10, 2014
    Posts:
    1
    I have a couple of questions regarding AssetBundle Variants.

    1. What is the benefit of AssetBundle Variants?
    Simulation mode is a huge improvement to our workflow. Why should we use Variants instead of separate AssetBundles?

    2. Why can't Variants be used in Simulation Mode?
    Is this a limitation of the AssetBundle Manager or is it a result of the underlying AssetBundle system?
     
  23. Anemor2000

    Anemor2000

    Joined:
    Jun 12, 2015
    Posts:
    39

    No one has a solution for that?
    I feel like I'll have to modify a good chunk of it to make it work offline.
    Thanks if you can help a bit.
     
  24. marf

    marf

    Joined:
    Jul 20, 2011
    Posts:
    122
    I have the same problem! How can I get the progress of a scene loaded from an AssetBundle so that I can display a progress bar of the loading status?

    Thank you,

    Marco
     
    ZeFirestarter likes this.
  25. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    481
    I have tried to write my own version of Load Scenes script for the web:
    Code (csharp):
    1. void Update()
    2.   {
    3.   if (!loading) return;
    4.   tx.text = "loading " + sceneName + " " + (100 * download.progress).ToString("0.0") + "%";
    5.   if (download.progress == 1.0f)
    6.   {
    7.   loading = false;
    8.   }
    9.   }
    10.  
    11.   IEnumerator LoadLevelCoroutine(string name)
    12.   {
    13.   sceneName = name;
    14.   sceneAssetBundle = name.ToLower() ;
    15.   tx.text = "loading " + sceneName;
    16.   string m_url;
    17.   string s_url;
    18.  
    19. #if UNITY_WEBGL
    20.   m_url = url + "/WebGL/" + "WebGL";
    21.   s_url = url + "/WebGL/" + sceneAssetBundle;
    22. #endif
    23. #if UNITY_WEBPLAYER
    24.   m_url = url + "/WebPlayer/" + "WebPlayer";
    25.   s_url = url + "/WebPlayer/" + sceneAssetBundle;
    26. #endif
    27.   Debug.Log(m_url);
    28.   WWW www = new WWW(m_url);
    29.   yield return www;
    30.  
    31.   AssetBundleManifest manifest = (AssetBundleManifest)www.assetBundle.LoadAsset("assetbundlemanifest");
    32.  
    33.   if (!manifest)
    34.   {
    35.   tx.text = "can't access manifest file";
    36.   yield break;
    37.   }
    38.   Hash128 version = manifest.GetAssetBundleHash(sceneAssetBundle);
    39.   www.assetBundle.Unload(false);
    40.  
    41.   s_url = url + "/WebGL/" + sceneAssetBundle;
    42.   download = WWW.LoadFromCacheOrDownload(s_url, version, 0);
    43.   loading = true;
    44.   yield return download;
    45.   AssetBundle asb = download.assetBundle;
    46.  
    47.   if (!asb)
    48.   {
    49.   tx.text = "can't access scene asset file";
    50.   yield break;
    51.   }
    52.   AsyncOperation async = Application.LoadLevelAsync(sceneName);
    53.   yield return async;
    54.   asb.Unload(false);
    55.   }
    The problem with it is that the download progress reaches 100%, and then:
    - in WebPlayer it does load the scene
    - in WebGL does not - I don't know why - so I had to reverse it back to the original script for WebGL builds.
    http://virtualplayground.d2.pl/WebGL/st15/galleries/comparison.php
     
    Last edited: Nov 24, 2015
    twobob and ZeFirestarter like this.
  26. faraz_b8

    faraz_b8

    Joined:
    Nov 23, 2015
    Posts:
    1
    Hey guys, thanks a lot for making this. It is good, but the error handling of this system makes it kinda un-usable for prod. I have seen many different exceptions (null pointer, file not found, ...). Is there a way we can get this code strengthened?
     
    Anemor2000 likes this.
  27. CaoMengde777

    CaoMengde777

    Joined:
    Nov 5, 2013
    Posts:
    813
    iam confused about handling MANY items .. do i load all the items in the game in the initial loading?
    or when each item comes into play? .. like when they are spawned or dropped out of the inventory or placed in a player characters hands..
    and do i make say, one asset bundle for all swords (like, 10) and their inventory icons, then another for all axes and their icons..
    or do i make an asset bundle for each individual item??
    (PC, ~50+ items)

    the reading ive done on asset bundles says you can only load a bundle once?? is that the whole bundle (say, 20 prefabs)? or like an individual item (prefab/sprite) in the bundle?
     
  28. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,670
    This really depends upon your needs and game design. I head that Rust uses one AssetBundle per object in the game, which gives them a very fine grained control, but this will also increase overhead, as each AssetBundle has a wrapper and headers and things that will be multiplied by every AssetBundle you need. IIRC, this is discussed in the AssetBundle Manager article linked in the original post. You will have to experiment so find out what works best for your game, your users, your target devices, etc.
     
  29. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,670
    Further contributions to the code can be made here:
    https://bitbucket.org/Unity-Technologies/assetbundledemo

    When we have a new stable release that has been through QA, we will update the AssetStore package.
     
    twobob likes this.
  30. SimteractiveDev

    SimteractiveDev

    Joined:
    Jul 9, 2014
    Posts:
    97
    I don't see it in the example, but is it possible to include the .meta files in the AssetBundle? Or are they already included, but just don't appear in the manifest?
     
  31. panosg_exient

    panosg_exient

    Joined:
    Aug 10, 2015
    Posts:
    1
    Hello,

    I am researching using asset bundles to do live updates for a game I am working on. The updates will most likely just be raw data updates like textures and meshes, no prefabs or anything like that.

    My main concern with the bundle manager demo is the use of LoadFromCacheOrDownload. It seems to be picking up updates to bundles fine, but at least on windows it looks like it keeps the old cached data too instead of replacing them with the newly downloaded ones. Is there a way to make LoadFromCacheOrDownload actually delete the old cache of the bundle? Is this behaviour the same for mobile devices too? (file size is very important there, I can't have a 4GB cache mostly consisting of old unused data)

    Aside from that, how safe is the cached data? Is it guaranteed to stay intact until the cache gets full?

    Do you think that asset bundles are the best choice for my use case?
     
  32. SimteractiveDev

    SimteractiveDev

    Joined:
    Jul 9, 2014
    Posts:
    97
    Hey, I've tried to get this working on iOS as well with no luck. So I decided to try the sample project on iOS device and it also does not work. It is failing to download the iOS bundle (note, the bundle is bundled with the app, not on a server). Seems like the paths are incorrect? This is the error:

    Code (CSharp):
    1. Failed downloading bundle iOS from /var/mobile/Containers/Bundle/Application/09287795-FB8E-466A-B25C-63B1CA55D80A/DreamResort.app/Data/iOS/iOS: unsupported URL
    Worth mentioning, I was testing the variant scene on an iPad mini.
     
    Last edited: Dec 3, 2015
  33. alphakanal

    alphakanal

    Joined:
    Jan 21, 2013
    Posts:
    34
    Hi! First of all - i'm new to developing with unity and maybe the worst coder on earth and thank you for this great tutorial !

    The SceneLoader Demo is perfect for me - because i'd like to load scenes to my Application only. And these scenes should be downloaded from the web. The Application itself is a WIN / MAC Standalone only... No Android / IOS or Webplayer.

    I'm trying to get the "SceneLoader" Demo modified to my belongings. All other files are deleted.

    When building the AssetBundles there are some files created in this folder: ProjectFolder\AssetBundles\Windows\
    • scene-bundle.manifest + scene-bundle
    • material-bundle.manifest + material-bundle
    • windows-bundle.manifest + windows-bundle

    I upload these file to the server and load them into the app. Works fine.

    But this way every time starting the app, it's loading the same files again from the server. How can i manage it, that once the assets are downloaded from the server the application will load them from local storage?

    Hope you'll understand what i'm trying to do and would be very happy for every hint :)
     
    Last edited: Dec 6, 2015
  34. ToroSheep

    ToroSheep

    Joined:
    Aug 7, 2014
    Posts:
    3
    Hello
    I tried to load two assets from an asset bundle at same time , the two assets were from different coding; but the asset bundle detected/counted just one asset (reference count = 1.) When I unloaded the 1st asset, the asset bundle would be released, and the 2nd asset was damaged (miss asset bundle).
     
  35. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    Full disclosure: This is our first foray into messing with bundles.

    TL,DR; We Served Files From Our IIS Server and Made Notes On How ;)


    TEST 1: (fail)
    We worked through the examples a couple of times using the webplayer and had difficulty.

    A) Convincing the Manager to detect the type as "Webplayer" - or "WebplayerStreamed". we ended up hard-coded it in the end to build out the bundles.
    Which exibits as the error:
    Code (csharp):
    1. ArgumentNullException: Argument cannot be null.
    2. Parameter name: path2
    3. System.IO.Path.Combine (System.String path1, System.String path2) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/Path.cs:115)
    4. AssetBundles.BuildScript.BuildAssetBundles () (at Assets/AssetBundleManager/Editor/BuildScript.cs:19)
    5. AssetBundles.AssetBundlesMenuItems.BuildAssetBundles () (at Assets/AssetBundleManager/Editor/AssetbundlesMenuItems.cs:27)

    B) We could not find a definitive source for the expected folder structure on the server side (presuming, however, it would be the one that was outputted by unity).

    C) The built files did not seem to serve from our server. The day ended.

    TEST2: (win)

    So, today we did a simple Windows build of the Scene Loader, no changes.
    Latest Download from GITHUB
    https://bitbucket.org/Unity-Technologies/assetbundledemo/downloads

    Adjust the Code to Suit your Needs
    Upon building the Player itself (after correctly building and subsequently distributing the Assetbundles to the server) we adjusted the code to allow development builds to pull from the web in <ProjectFolder>\Assets\AssetBundleSample\Scripts\LoadScenes.cs (Line 31)

    Reference Image

    Our final file, that we ended up with for the live testing, was:
    LoadScenes.png
    Don't leave off the the trailing slash "/" , Clearly the workflow of the code in this file might be different for everyone but it illustrates the expected path structure nice and clearly.

    We ran this build and then went and checked our weblogs.

    Check your facts
    The actual requested URL seems to involve a double use of the BuildTarget; as a folder; and a name. We checked these existed. They did.

    upload_2015-12-15_12-52-41.png

    Check Your Logs
    We checked the log did actually reflect a request for that file. It did.

    Code (logs):
    1. #Date: 2015-12-15 12:02:56
    2. #Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
    3. 2015-12-15 12:02:56 198.239.139.39 GET /<webFolder>/unityTest/AssetBundles/Windows/Windows - 80 - 99.199.191.298 UnityPlayer/5.3.0f4+(http://unity3d.com) 404 0 2 46
    However the keen eyed will note the 404 meaning it was not served. (It may be possible for you to get a 403 or a 401 we think based on your individual server config... however...digress)

    This means the config must be wrong on the server.

    Configure your Server
    THE IIS MANAGER WAY:

    A quick google tells us we can allow a certain folder on IIS to serve all that folder's sub-files via an additional local entry in the MIME type section (of that particular folder) in the IIS manager.

    The Extension would be . (That is a single "period", or "full-stop" if you prefer)
    The type would be application/octet-stream
    It would look like this:
    IIS-Config-Local-Serve-All-.jpg

    THE MANUAL WAY
    Drop a file called web.config in the folder with the contents:
    Code (xml):
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <configuration>
    3.   <system.webServer>
    4.   <staticContent>
    5.   <mimeMap fileExtension="." mimeType="application/octet-stream" />
    6.   </staticContent>
    7.   </system.webServer>
    8. </configuration>
    NOTE: IF YOU DELETE THIS FOLDER YOU HAVE TO DO THIS STEP AGAIN. (since the web.config file has gone)

    Using Lamp Servers
    This DID allow for the correct serving of files under IIS however. N.B: You may have to check your other access permissions et cetera on other platforms such as LAMP and will have to use the relevant server-specific equivalents.

    Note for testing "WebServer" target
    If you DON'T see any entries in the logs (after you have succesfully tested a windows target first) then your next step would be checking the servers crossdomain.xml file. Ensure you have a valid one. Here is an example:
    Code (csharp):
    1. <?xml version="1.0"?>
    2. <cross-domain-policy>
    3. <site-control permitted-cross-domain-policies="all"/>
    4. <allow-access-from domain="http://yoursite.co.uk" secure="false"/>
    5. <allow-http-request-headers-from domain="http://yoursite.co.uk" headers="*" secure="false"/>
    6. </cross-domain-policy>

    Extra note on servers that honor canonical subdomain requests silently.
    Quite a title, what does that mean? Some server configs will serve out the same content on www .yoursite.com and yoursite.com, etc.

    To the end user it makes little difference however: With the cross-domain-policy The subdomain matters. If you lock the crossdomain.xml to your main "non-sub-domain" site URL (as shown above) you need to use the same, single, specific "non-sub-domain" when serving out your files, request from other subdomains will be denied. If using a subdomain instead, only that subdomain would work and requests from the main site would be denied.

    To ensure the correct sub/domain is referenced you can control the URL via a little javascript injected into the WebPlayer.html
    Code (csharp):
    1. <script  type='text/javascript'>
    2.      if(window.location != 'http://yoursite.co.uk/folder/')
    3. window.location.replace('http://yoursite.co.uk/folder/')
    4.    </script>
    all subdomain request will be put back to the main domain in this example :), the requirement for this depends on your server honoring requests like "www" canonically in it's config.

    Profit
    And here it is working via the web from a local Windows build.
    upload_2015-12-15_13-23-44.png

    And here it is working with the webplayer, 4.5Mb multiplayer world, rest streaming in.
    upload_2015-12-15_19-30-38.png

    Hope this helps someone else.
     
    Last edited: Dec 16, 2015
    John-G, hopeful and AdamGoodrich like this.
  36. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    Simple Sanity Tester for listing Bundles in project...
    Props arcanor for the original derping

    Gisted https://gist.github.com/twobob/0391e67f2825ec024337#file-listbundles-cs
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using System.Collections;
    4.  
    5. public class ListBundles : MonoBehaviour
    6. {
    7.     [MenuItem("Assets/AssetBundles/List AssetBundles %#l")]
    8.     static void List()
    9.     {
    10.  
    11.         Debug.Log("<color=#ffff00ff>Search Initialised</color>, patience");
    12.         string assetPath = string.Empty;
    13.         string bundleName = string.Empty;
    14.         foreach (var assetGuid in AssetDatabase.FindAssets(""))
    15.         {
    16.             assetPath = AssetDatabase.GUIDToAssetPath(assetGuid);
    17.             bundleName = AssetImporter.GetAtPath(assetPath).assetBundleName;
    18.             if (string.IsNullOrEmpty(bundleName))
    19.             {
    20.                 continue;
    21.             }
    22.             Debug.Log("Found asset: (GUID:<color=#00ffffff>" + assetGuid + "</color>) " + assetPath + ", AssetBundle: " + bundleName);
    23.         }
    24.     }
    25. }
    Hope it helps.
     
    Last edited: Dec 15, 2015
    paw9000 and AdamGoodrich like this.
  37. chmodseven

    chmodseven

    Joined:
    Jul 20, 2012
    Posts:
    38
    Is there a way to set the BuildAssetBundleOptions choice when using the manager? I would like to ensure that ChunkBasedCompression is being used for some particular bundles.
     
  38. frank28

    frank28

    Joined:
    Dec 30, 2013
    Posts:
    12
    Hi,

    I've got a question about "Automatic unloading of asset bundles" feature listed in the project's overview page on bitbucket:

    Through the code, I've found the UnloadAssetBundle() method which should do the job, however, I didn't see it was called anywhere in the Demo.

    And in fact, that's my question: when should I call this UnloadAssetBundle in a project? After a GameObject is loaded from AssetBundle? If it's the case, then why you use a Reference Counting for every bundle loaded? That doesn't make any sense IMHO. I'm really appreciate if you could help me to solve this puzzle.
     
  39. memetic-arts

    memetic-arts

    Joined:
    Feb 27, 2011
    Posts:
    82
    Did you ever find a solution to this? I am having a similar issue, though, unlike you, I can't get it working via the web at all (even from OSX standalone). I am getting this error:

    Failed downloading bundle OSX from OSX: Couldn't resolve host 'OSX'
    UnityEngine.Debug:LogError(Object)
    AssetBundles.AssetBundleLoadAssetOperationFull:IsDone() (at Assets/AssetBundleManager/AssetBundleLoadOperation.cs:190)
    AssetBundles.AssetBundleLoadOperation:MoveNext() (at Assets/AssetBundleManager/AssetBundleLoadOperation.cs:17)

    I'm using the code right out of the tutorial, with this URL:

    Code (csharp):
    1. AssetBundleManager.SetSourceAssetBundleURL("http://www.mysite.com/AssetBundles");
    And, since the local version generates an OSX folder for the bundles automatically, I've tried including that in the path as well . . . either way, the error message is the same.

    Are you certain that you had it working from the web, and maybe hadn't simply commented out the local server version of the SetSource code?

    Thanks in advance, would really appreciate the insight . . .
     
    lior_rosenspitz likes this.
  40. memetic-arts

    memetic-arts

    Joined:
    Feb 27, 2011
    Posts:
    82
    Hello again. So, realizing that this thread is really about the tutorial, and my post above is more about general support, here are a couple of questions/comments about the tutorial:

    1. If the ABM approach is supposed to be "the way", then why does the Manual say "The recommended way to download AssetBundles is to use WWW.LoadFromCacheOrDownload"? This method is not used in the any of the loader scripts (at least not the version that I downloaded). Some cohesion and clarity across both pieces of documentation would be helpful.

    2. I've been using Unity for a while, but am new to AssetBundles. So if you were to provide, in the tutorial, some information as basic as how to properly construct the URL, this would be very helpful. Because when you use the ABM to generate bundles, a folder is automatically created that represents the platform (iOS, OSX, etc.), however it is not immdediately clear as to whether you need to preserve that structure when deploying the AssetBundles to the web. Given the errors that I'm getting (see above post), it would seem so, but then no matter what folder structure I try, the error is the same.

    I've seen a fair amount of questions in various forums about these things, with no explicit answers . . . any help would be appreciated.
     
    Last edited: Jan 16, 2016
    lior_rosenspitz likes this.
  41. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    Hi, as outlined reasonably extensively here http://forum.unity3d.com/threads/the-assetbundle-manager-tutorial-q-a.354400/#post-2424116 that URL configuration is correct.
    Other than Don't leave off the the trailing slash "/"

    We outline a simple testing methodology to double check your server is capable of serving out the "nul" extension files, currently looks like yours might not be, hard to tell until you fix the URL, hope that helps.
     
  42. memetic-arts

    memetic-arts

    Joined:
    Feb 27, 2011
    Posts:
    82
    @twobob, thanks for the reply, especially on this holiday weekend. :)

    I did try the trailing slash -- after reading your post -- and while it did offer a glimmer of hope, and while the error message did change from a NullReferenceException to a 403-Forbidden error, it still didn't work.

    As you'd also said in your post that the 403 was indicative of server config issues, I did go to my server's Mime-type Manager, and it would not accept a single "." as the extension (instructional text there says:
    > in the format ".fileextension.txt". Ex. name.txt

    So . . not sure what to input there exactly. Thoughts?

    Thx again . .
     
  43. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    screenie of interface that wont play ball?

    sounds like it is indeed a hosting issue then

    simply dump the Web.Config snippet I provided in the folder then.

    One (using the interface) simply produces the other (the web.config file in the right folder) anyway...

    Code (xml):
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <configuration>
    3.   <system.webServer>
    4.   <staticContent>
    5.   <mimeMap fileExtension="." mimeType="application/octet-stream" />
    6.   </staticContent>
    7.   </system.webServer>
    8. </configuration>
    perhaps this configuration is /not/ disallowed on the server level, merely nerfed in the interface to prevent idle misconfiguration. I would certainly derp on it
     
  44. memetic-arts

    memetic-arts

    Joined:
    Feb 27, 2011
    Posts:
    82
    Thanks . . . I did actually try that as well (I did read your post! :) ), and it doesn't seem to have worked, unless there is some kind of a delay on my hosting service that might prevent the immediate effect of the file (I seem to recall that a similar issue a while back required for their servers to "cycle" through a daily sweep). So maybe it worked, maybe not, will know for sure tomorrow.

    I actually did go back to the Mimetype Manager and realized that I may have input the extension incorrectly -- as they were looking for ".extension.txt", and in this case the extension was simply ".", I input "..txt", and it took. But as I said, no idea whether it's worked or not (as of now it hasn't).

    In the meantime, I did try, just for kicks, hitting the files via the browser, and on hitting http://www.mysite.com/AssetBundles/OSX got a "not authorized" message; when hitting mysite.com/AssetBundles/OSX/scene-bundle, got a bunch of code in the screen . . . not sure if that means anything, but that's what's happening.

    Thank you again for the assist and the input, really do appreciate it!
     
  45. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    Hmm. Sounds odd.

    Should have immediate effect. The .config file only affects the folder it is in so should be okay.
    So you have full IIS admin level access then?

    Only thing I can advise is check your logs following the same logic we did. "Is the request going there, is it being served." In your case it most certainly seems like a config issue now.

    Perhaps just try creating a single NON-extension file "yourfile". And try serving it from a known URL.

    yoursite.com/yourfile, until you get that working the rest of this won't work; and this approach takes everything else - other than the server config - out of the loop.
     
  46. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    the extension is a single period ".", nothing else, like in my screenie.
     
  47. memetic-arts

    memetic-arts

    Joined:
    Feb 27, 2011
    Posts:
    82
    Your interface is different than mine . . just confirmed that I'm on Linux, not IIS . . . would that make a difference, though? MIME Types are MIME Types, right?

    In any case, the hunt is on for the proper config, will report back with progress.

    Thank you again for your help!
     
    Last edited: Dec 28, 2015
    twobob likes this.
  48. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    Yeah. Thus your hosting environment would not respect the web.config, hence asking for piccies ;)

    Therefore - assuming apache -

    http://httpd.apache.org/docs/2.2/mod/core.html#defaulttype

    I believe a .htaccess file is the equivalent of the web.config, Hope it helps.

    On Linux file/folder permissions are critical, you should check with your host their recommended settings.
     
    Last edited: Dec 28, 2015
    memetic-arts likes this.
  49. memetic-arts

    memetic-arts

    Joined:
    Feb 27, 2011
    Posts:
    82
    EDIT (31DEC2015): PLEASE NOTE: Regarding the issues outlined below, I finally correctly identified and SOLVED the issue I was having, which primarily was the inability to properly pass and set the remote server URL for accessing my assetbundles.

    In the end it was not the AssestBundleManager.cs file at all, but rather the LoadScenes.cs file. Since my normal workflow (and I'd expect others' as well) is to fully test in the Editor before building to the platform, my immediate goal was to have the remote import working end-to-end. And I'd apparently overlooked the fact that the call to SetSourceAssetBundleURL was positioned in the ELSE of the if/else testing for whether the script was running in the editor or not. In other words, because I was running it in the editor, the call was never being executed. As soon as I moved it out, everything worked as expected.

    I'm not sure why one would assume that you would only hit a remote server if you are not in the Editor, but that apparently was the case.

    I'm leaving the rest of this post intact for "truth-in-history" purposes, but it is largely invalid now. And apologies for consuming so much page-space . . . I suppose if the admins would rather delete the series of related posts following this, I'd be ok with that. :)

    Cheers

    ==============================================

    [original post]

    Well, I've been down quite the rabbit hole . . . and after much research, trial and terror, etc., I've finally identified the problem I was having, which, as I'd initially reported, was centered on this error:

    Failed downloading bundle OSX from OSX: Couldn't resolve host 'OSX'
    UnityEngine.Debug:LogError(Object)


    There were some subsequent errors showing up, but the one above was the main event. @twobob had suggested that it was MIME type-related, and after some further research, I've found that to NOT be the case. twobob, thanks for the help . . . I know things were pointing that way, but the issue is actually much simpler.

    In the end, there is either a coding error in the AssetBundleManager.cs file, or there is lack of sufficient documentation as to how to properly implement the functionality, that being to pull in the assets from an actual (not simulated) web server.

    The bad news is that while I've identified and proved-out the issue, I don't actually know how to properly fix it, so I'm hoping that @Adam Buckner or someone out there will be able to provide the answer.

    As the goal was to load a scene using the LoadScenes.cs script, the issue may actually start with this call to AssetBundleManager.cs, to pass the URL of the bundle:

    Code (CSharp):
    1. AssetBundleManager.SetSourceAssetBundleURL("http://www.mysite.com/AssetBundles/OSX");
    NOTE: The trailing "/" is left off here, despite @twobob 's instruction, as it seems that the manager code (below) appends it to the passed url string (see below). Granted, the function doesn't seem to be working, but here's hoping.

    There are actually four code blocks in AssetBundleManager.cs that are potentially impacted. First, in the beginning of the file, we find this declaration of the m_BaseDownloadingURL on Line 44, set to an empty string:

    Code (CSharp):
    1. static string m_BaseDownloadingURL = "";
    Now, if we jump down to Line 311, we see this, in which the variable url is set; this value is then used to process the bundles and manifests:

    Code (CSharp):
    1.  
    2. WWW download = null;
    3. string url = m_BaseDownloadingURL + assetBundleName;
    4.  
    The problem is that m_BaseDownloadURL is never set after it is first declared, so the string is still empty. If I replace the variable with a hardcoded string containing the URL that I passed from LoadScenes.cs, the functions run, and I get a nice cube with the Unity Logo floating in space, as expected.

    So then why isn't it getting set? The function called from LoadScenes.cs, SetSourceAssetBundleURL, to which we pass the URL string, looks like this (starting on Line 134):

    Code (CSharp):
    1.  
    2. public static void SetSourceAssetBundleURL(string absolutePath)
    3. {
    4.     BaseDownloadingURL = absolutePath + Utility.GetPlatformName() + "/";
    5. }
    6.  
    Notice that the variable is "BaseDownloadingURL", not "m_BaseDownloadingURL".

    Now, there is this block, in which BaseDownloadingURL is getting/setting m_BaseDownLoadingURL -- and I'm not sure why this is necessary -- but it doesn't seem to be working. This runs from Lines 64-69:

    Code (CSharp):
    1.  
    2. // The base downloading url which is used to generate the full downloading url with the assetBundle names.
    3. public static string BaseDownloadingURL
    4. {
    5.     get { return m_BaseDownloadingURL; }
    6.     set { m_BaseDownloadingURL = value; }
    7. }
    8.  
    Maybe it's because "value" is never declared, passed or defined? I have no idea. So again, if anyone knows how to fix this properly, I'd really appreciate the input.

    End of story, for now . . . cheers.
     
    Last edited: Dec 31, 2015
    Muckel likes this.
  50. memetic-arts

    memetic-arts

    Joined:
    Feb 27, 2011
    Posts:
    82
    Also . . . a couple of other nuggets that would be helpful in the tutorial:

    1. When you FTP your assetBundles / manifests files to your server, make sure you have the Transfer Type set to "binary". (that's in FileZilla, but I'm assuming there is a similar setting in other FTP tools). Forget where I spotted that, but that was a definite "Aha!" moment . . .

    2. When building to iOS, make sure that in your Player Settings, the option for "Strip Engine Code" (in the "Optimization" section) is UNCHECKED. Spotted that in the XCode build logs after an initial failed attempt, and lo-and-behold, it worked.

    Good luck!
     
    Muckel, ZeFirestarter and twobob like this.