The AssetBundle Manager Tutorial Q&A

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.

2 Likes

Glad to see this updated after the ā€œincidentā€ :smile:
Great stuff @Adam-Buckner_1 this info is sorely needed

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.

Thread tagged for reference (when my mind wanders :smile:)

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.

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 ();

1 Like

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.

2 Likes

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.

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.

1 Like

Is there a way to include baked lightmap data in AssetBundels when loading a scene?

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.

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)

ok, how about also explaining exactly what is in the ā€˜AssetBundleServer.exeā€™ :smile: 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 :smile:

[edit]

ok, iā€™m starting to put it together in my mind (ILSpy, thanks :smile:)

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.

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?

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ā€™.

2 Likes

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.

Is there any way to suppress generation of .manifest file while exporting assetbundles?

How to get the loading progress when loading a scene from AssetBundles?

1 Like

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.

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.