Search Unity

  1. We would like to hear your feedback about Unity and our products. Click here for more information.
    Dismiss Notice

Clarification on Workflow for bundling Scenes for DLC

Discussion in 'Asset Bundles' started by hoperin, Jun 12, 2019.

  1. hoperin

    hoperin

    Joined:
    Feb 9, 2014
    Posts:
    50
    So, I'm working on figuring out how to structure DLC bundles that can be loaded & unloaded as needed to save space on people's devices. AssetBundles are obviously the way to go, but I am unclear on the best practise for splitting things up.

    The DLC wouldn't be new skins or items, but rather entire scenes of new content, so I am leaning towards making assetbundles containing whole scenes. However, all scenes have core objects that are present across all scenes ie UI, managers. According to the docs, these core objects will be present in every asset bundle?

    "If multiple objects in multiple bundles contain a reference to the same object that isn’t assigned to a bundle, every bundle that would have a dependency on that object will make its own copy of the object and package it into the built AssetBundle."

    This, to me, feels really inefficient and like something that you would want to avoid, but the documentation just seems to state it as is.

    The only way I can think to avoid this by is putting any new DLC scenes in a patch in the main build, but package all of the contents that are exclusive to the new scene in an asset bundle? That already seems much less ideal than just loading a whole scene, but would I also then have to instantiate all the contents of the asset bundle back into the scene? I feel like I must be going about thinking about this wrong.

    Thanks in advance!
     
  2. ligangwei

    ligangwei

    Joined:
    Feb 1, 2017
    Posts:
    2
    You'd solve this by packing shared assets into a separate bundle. (This is really easy with AssetBundleBrowser, something like right click -> select pack duplicated assets into blah blah blah)

    Lets say you have 6 bundles:
    1. StandaloneWindows (assuming this is your platform)
    2. shared (assets that shows up in pretty much every stage)
    3. core
    4. stage1 (scene bundle)
    5. stage2 (scene bundle)
    6. dlcstage3 (scene bundle)
    Lets assume these 6 bundles are shipped with the main build. When time comes for you to release your new dlc, you'd maybe add a seventh bundle called dlcstage4 right? Assuming dlcstage4 uses some assets in the shared bundle, and nothing else is changed, when you build the asset bundles, only bundle 1 will be changed(since it contains the names to all the other bundles, obviously this will be updated when you add a bundle), bundles 2-6 should remain the same.

    You can then probably figure out some sort of delivery, something like always getting StandaloneWindows on start up(it's really small), loading the AssetBundleManifest from it to see if there are any new bundles, download if there are, and load the scene from that bundle when you want to(I assume it's going to be a scene bundle).

    As for whether or not you need to manually load all the assets that were extracted into the shared bundle, the answer is no, Unity magically does it for you, as long as all the dependencies of a bundle is loaded, Unity will load everything an assets need from whatever bundles they're from when you load the main asset.
     
    MrMatthias likes this.
  3. hoperin

    hoperin

    Joined:
    Feb 9, 2014
    Posts:
    50
    Ahh, thank you so much! This is really good news to hear, and makes what I have to do moving forward a lot clearer!