Search Unity

from Resource to Asset Bundle

Discussion in 'Asset Bundles' started by laurentlavigne, Jan 31, 2017.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,325
    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)
     
  2. Reichert

    Reichert

    Unity Technologies

    Joined:
    Jun 20, 2014
    Posts:
    63
    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.
     
    laurentlavigne and mahdi_jeddi like this.
  3. hiroki-unity

    hiroki-unity

    Joined:
    Jun 20, 2013
    Posts:
    21
    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.
     
  4. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,325
    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 :)

    The documentation on the asset pipeline (https://unity3d.com/learn/tutorials...tbundle-usage-patterns#Managing_Loaded_Assets) talks about file handle, Object's lifecycle and other things which I don't quite understand. Is this what the upcoming workflow will tackle?
     
  5. Reichert

    Reichert

    Unity Technologies

    Joined:
    Jun 20, 2014
    Posts:
    63
    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
     
  6. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,325
    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?
     
  7. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    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?
     
  8. Reichert

    Reichert

    Unity Technologies

    Joined:
    Jun 20, 2014
    Posts:
    63
    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.
     
  9. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    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 :p
     
  10. Reichert

    Reichert

    Unity Technologies

    Joined:
    Jun 20, 2014
    Posts:
    63
    We have a draft of a complete rewrite of the existing documentation in the Unity manual. Coming soon :)

    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.
     
  11. ninuxw

    ninuxw

    Joined:
    Jul 8, 2014
    Posts:
    26
    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 :( Even tutorials are all focused on the use of bundles for patching not for migrating.

    Thanks in advance for the answer!
     
    laurentlavigne likes this.
  12. Reichert

    Reichert

    Unity Technologies

    Joined:
    Jun 20, 2014
    Posts:
    63
    Yes it is - watch this Unite presentation from November to learn about what we're up to:
     
    Stormy102 and laurentlavigne like this.
  13. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,325
    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?
     
  14. ninuxw

    ninuxw

    Joined:
    Jul 8, 2014
    Posts:
    26
    Me like! Thanks!

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

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    <3
    This will solve all our problems with asset bundles! You and your team deserve a pay rise!
     
  16. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
  17. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,325
    @hiroko
    Gentlemen, we're in the future now, so, how do I "seamlessly transition" to bundles?
     
    AcidArrow and grobonom like this.
  18. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,723
    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?
     
    JoshuaSPine likes this.
  19. senfield

    senfield

    Joined:
    Apr 1, 2019
    Posts:
    31
    Text mesh pro still relies on Resources. The future feels far away.
     
    Neto_Kokku and Prodigga like this.
  20. jhughes2112

    jhughes2112

    Joined:
    Nov 20, 2014
    Posts:
    178
    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.
     
  21. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    Instead of automatic transition from resources to asset bundles, we got an asset bundle manager that can't even load stuff synchronously out of the box, likes to rebuild bundles needlessly and is somehow slower when dealing with hundreds of bundles.

    The future has been canceled.