from Resource to Asset Bundle

I use Resource a lot for loading streamed dialogue. I see in the doc that Asset Bundles are preferred, does that apply in the case of streamed audio? And how can the new AB graph editor help transition from resource folder (which is so easy to deal with) to AB (not so much)

We have a plan to seamlessly transition the build process and Resources API to utilize asset bundles automatically. You won’t have to do anything differently, at least initially. After that, we will provide some workflows that will make it very simple for you to transition assets to bundles that are packaged for CDN distribution. We’ll have more details about this API transition in the near future.

2 Likes

laurentlavigne, thank you for making the good point. This is one of the area we have been targeting to improve. AssetBundleGraphTool does not directly offer API level replacement today. Please look forward for our update.

Oh I see, like the script updater does for deprecated API. Access to Resource and AB is very different so this automated updater doesn’t sound trivial so thank you for taking that on :slight_smile:

The documentation on the asset pipeline (Assets, Resources and AssetBundles - Unity Learn) talks about file handle, Object’s lifecycle and other things which I don’t quite understand. Is this what the upcoming workflow will tackle?

Yes, we believe most developers should not have to worry about the asset build process or runtime asset management at the level required today for asset bundles. Some developers do, and we will provide better APIs for that case as well.

Here is a very high level vision of what the future looks like:

  1. When you create a build, assets will be packaged into asset bundles by default, including resources, and all existing APIs for loading/unloading assets will work as expected.

  2. When you decide it’s important to optimize your build/player size, transitioning assets out of resources and into discreet bundles with shared dependencies will be seamless. Doing so will also provide better memory management, as we will be able to track loaded assets & instantiated objects against their source bundles, and automatically unload the bundles when they are no longer in use.

  3. When you want to then segment content for over-the-air distribution, we will provide simple interfaces for configuring CDN endpoints and marking assets in an appropriate way that will inform the build process of your intentions, and it will be clear which bundles need to be uploaded for hosting.

  4. When you are ready to patch an already deployed game, we will provide build options that will create optimized bundles for patching vs. full replacements. Initially these patches will likely be at a per asset level, but eventually will be at the per-byte level.

-Stephen

3 Likes

This looks like an awesome phase 1. Thanks for sharing the plan. I must admit AB stayed under my radar until I had to pay attention to memory on mobile.
It is probably a bit off topic but for some reason it resonates with me: The distinction between a scene and an instance seems artificial, are there plans to merge those?

This looks really cool and a great transition. So, instead of being in sharedassetsX.asset, the option will be available to use something like AssetBundleGraph to package the assets into different locations. Will the option to export assets to a specific path be available like Data/Bundles?

The idea with supporting the existing Resources magic folders is to keep it fully backwards compatible with the existing Resources load APIs. This requires making sure 1) all assets in resources are packed into one or more bundles that are builtin to the player so synchronous loads work and 2) we don’t allow dependencies on assets in bundles that are outside of builtin bundles, for the same reason.

So in order to control your asset bundle layouts and prepare for using CDNs to distribute bundles, you will need to move assets outside of resources folders, and explicitly mark which assets are addressable (so they can still be found by the Resources APIs). On the client side your loading code will only have to change slightly if you need to load asynchronously from hosted bundles.

Ah ok gotcha! So I can effectively create that on my backend and customise it to my liking. I just feel that more documentation would make it easier for developers to dip their toes into the assetbundle lifestyle :stuck_out_tongue:

We have a draft of a complete rewrite of the existing documentation in the Unity manual. Coming soon :slight_smile:

Ultimately though we are going to make this really nice so you don’t have to think about it much at all, other than marking addressable assets and the minimal configuration necessary to support hosting your bundles.

3 Likes

Hi! Is #2 still on the works? I am trying to find a simple way of transitioning from my heavy used resource folder to using asset bundles.

Have had no luck :frowning: Even tutorials are all focused on the use of bundles for patching not for migrating.

Thanks in advance for the answer!

1 Like

Yes it is - watch this Unite presentation from November to learn about what we’re up to:
https://www.youtube.com/watch?v=t7O1pO8HFRU

2 Likes

first of all:

now addressables, I like how you move the responsibility of building AB to some snap on component, are they in some shape or form available?

Me like! Thanks!

Do you know if this would be available by june/july?

<3
This will solve all our problems with asset bundles! You and your team deserve a pay rise!

Hi @Reichert . Does ResourceManager addressed game object pooling issue too? Refer to: Request gc free gameobject.name API - Unity Engine - Unity Discussions

@

Gentlemen, we’re in the future now, so, how do I “seamlessly transition” to bundles?

2 Likes

If I understand correctly this meant that Unity would auto split a project (even direct references, not just stuff in Resources folder) into asset bundles when building and you could have a reasonably split game for delta patching, without having to change anything?

Has this happened (I’m guessing, no?) will it happen?

1 Like

Text mesh pro still relies on Resources. The future feels far away.

2 Likes

The whole Resources API should be deprecated entirely… just a bunch of 3rd party libs use it.

For what it’s worth, you never want to use Resources if you can avoid it. Loading anything from there doesn’t use threads at all, so it blocks the main execution context. Consider using AssetBundles instead. Even if they are built and shipped along with your application, it’s better for load times and asset compression etc.

Shameless plug… if you want to use my AutoBuilder asset, it has a really trivial API that you can swap in without changing any other code. Or change it slightly and get fully async loading.