Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

How to use Addressables to implement DLC on Steam?

Discussion in 'Addressables' started by ArchSantaZ, Jun 25, 2020.

  1. ArchSantaZ

    ArchSantaZ

    Joined:
    Oct 4, 2019
    Posts:
    9
    Hi guys,

    I've been learning Addressables system for 1-2 days so that I may use it to implement DLC bundle for my game on Steam. But I'm still confused and not sure how to achieve this.


    Here is my scenario.

    The DLC bundle will contain many additional scenes and other assets.

    My plan is to:
    1. Use addressables system to pack those scenes together and ship it to steam in DLC depot.

    2. Once user purchases DLC from steam, Steam client should automatically download the DLC content and merge them to the game folder (Maybe in StreamingAssets/aa/<something> ?)

    3. Player launch the game. The game checks if DLC content is available and displays level select UI based on it. (Not sure how to check)


    So my questions are:

    1. How do I setup BuildPath and LoadPath in the profile to achieve this? Local or Remote? Or should it be a custom? Because steam will take care of the content download process, is it possible use LocalBuildPath and remove it from the main build for the main content without DLC?

    2. How to check if the DLC content is already downloaded? I've tried using
    Addressables.GetDownloadSizeAsync but it always return 0 even when the DLC content does not exist.

    3. If the all the prefabs in the addressable scenes are addressables too. Do I need to instantiate them from the code to make it work? Or I can just include them in the scene as usual?


    Not sure what are the best practices for this. I could not find it on the internet myself.
    If you have other approach to achieve this, please tell me :)
     
    Fishing_Cactus likes this.
  2. ambid17

    ambid17

    Joined:
    Jun 28, 2017
    Posts:
    7
    Adding a comment here in case this gets answered. There's so little documentation out there this is hard to figure out
     
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,994
    There is a lot of documentation, it's just worded in a very abstract way so it's super hard to understand.

    What it needs are real life scenarios and how they're used.

    Then abstractions and behind the scene tech.
     
    Last edited: Jul 1, 2020
  4. GroundCombo

    GroundCombo

    Joined:
    Jan 23, 2015
    Posts:
    29
    I haven't done much with Addressables yet (we used raw asset bundles in our last game), but for this you can simply use the GetDLCCount(), GetDLCDataByIndex() and IsDLCInstalled() functions in the Steam API.
     
  5. ArchSantaZ

    ArchSantaZ

    Joined:
    Oct 4, 2019
    Posts:
    9
    Thank you for your suggestion :)
    I'll try that way.
     
  6. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,418
    Going to bump this since I'm also interested in some best practices.
     
  7. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    659
    Please! I am also eager to know more about this.
     
  8. Shaunyowns

    Shaunyowns

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    328
    I'll see if I can get a response from the team on this topic!
     
  9. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    659
    Thank you! I am sure a lot of people would really appreciate this!
     
  10. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    1,053

    So I'll answer these as best I can, but the short bit of context to know is that all platforms manage their content differently. Addressables can handle loading things from paths and URLs, but does not have things like steam-specific APIs integrated.

    1. BuildPath will need to just be some folder outside of assets. like "project/DLC". we'll build the content there, then you give that to Steam through whatever mechanism steam provides for this. I have not uploaded dlc to steam before, so I don't know what that is. As to the LoadPath, this is wherever steam puts your stuff. Again, I don't know where that is. I have a feeling it's not in your StreamingAssets folder, as that's a Unity specific thing, and Steam wouldn't know to put it there. But I have no idea. You'll have to find out from steam where DLC goes once downloaded. Wherever that is, set that as your LoadPath. OR it could be that Steam downloads to dynamic locations. If that''s the case, and they've provided an API for your code to ask them "where is my dlc", then you'd want to set your LoadPath to some variable to be evaluated at runtime. https://docs.unity3d.com/Packages/c.../manual/AddressableAssetsProfiles.html#syntax might be a useful reference here.

    2. Unity (or Addressables) doesn't download the content. Steam does. Which means you have to ask Steam if it's downloaded. I'd assume they have an API for this. Sounds like someone in this thread already referenced them.

    3. This question feels unrelated to steam DLC. You seem to be asking the general question of: if a prefab is included in a scene, does it need to be addressable (if the scene is). The answer is: you don't, unless you want to... For the scene to load that prefab, no. During build all prefabs that are included in scenes are flattened into that scene. And all things built that have a direct reference to a prefab will pull that prefab in. The only reason you'd have for making a prefab addressable is if you wanted to have a weak reference to it (AssetReference or address) such that you could load it on demand. If it's referenced in the scene, it's loaded with the scene. So essentially the answer here is "either way works, so it's up to you and your memory management plan"
     
  11. LuGus-Jan

    LuGus-Jan

    Joined:
    Oct 3, 2016
    Posts:
    169
    Hi @unity_bill

    I've been following this thread in the hopes to get some clear answers on this as well. We've released our game on Steam a few years ago and I can pretty much confirm your first 2 answers:

    1. DLC locations are partly configured on the SteamWorks partner website whether DLC lands next to executable of the main game or somewhere else. These files need to be uploaded using tools from Steam after which it will take care of distributing and downloading. There's no way Addressables can assist in that process and is something that should be queried using the SteamWorks.NET SDK.

    2. The SteamWorks SDK indeed has some calls for that. You can both ask if a particular DLC package is owned and installed by the player (
    SteamApps.BIsDlcInstalled()
    ) as well as where it is installed (
    SteamApps.GetAppInstallDir()
    ). The last one can be used to load additional catalogs for DLC packages and which is what we use.

    About the 3rd answer, I still have a similar question as it is something I've been trying to optimize both our build times and build sizes. Please allow me to elaborate a bit more on our situation. So we have our main game and 1 DLC pack. The main game contains a lot of assets brought under the Addressables umbrella (music, scenes, items players can use to create custom content, etc.). Our DLC pack just contains some extra music tracks and a 'night time' variation of our existing levels. I've ran the fixable analization rule to check which assets are pulled in by our scenes implicitly (for both the main game as well as the DLC pack) and set apart these implicit assets in their own groups, i.e. shared-shaders, shared-materials, shared-textures, etc. After I've done this and I make a new build of our main game only, the build size is shrunk extremely (nice!). We went from ±17GB to ±11GB. So this is what I want. But when I build my DLC pack, the build size remains the same, which is relatively big for just the same scenes with some different post processing effects turned on and different skybox. I was expecting the DLC pack to profit from this change as well (and we kind of need it to) in order to reduce our time building and uploading the whole thing. I suspect that, because they are build in separate build passes (different Addressable profiles), they don't include them to be taken up in the whole DLC situation.

    What is the recommended strategy here? I've included some screenshots of our settings as well as which groups are built for which pass.

    Addressable asset settings:
    AddressableAssetSettings.png

    Settings for scenes group built with main game (similar settings apply for other groups built with the main game):
    StandardScenesSettings.png

    Settings for scenes group built with DLC package (similar settings apply for other groups built with the DLC package):
    DLCSceneSettings.png

    Groups built during the main game build pass (custom data object for our build process to state which bundles need be built):
    StandardGroupsBuilt.png

    Groups built during the DLC package build pass (custom data object for our build process to state which bundles need be built):
    DLCGroupsBuilt.png

    I suppose it's not necessary to re-include the 'shared' groups to be included in the DLC build if they are already shipped with the main game? But I have the impression they need to be if they want to benefit from the build optimization. But what about the duplicate bundles that will get loaded? They throw an error when a bundle with the same ID has already been loaded.
     
    Last edited: Oct 12, 2020
  12. CCrowell

    CCrowell

    Joined:
    Mar 31, 2022
    Posts:
    8
    I have a similar issue where a client wants to be able to bundle groups of assets together but it seems to me the addressable system assumes that all of the addressables are stored/updated in the same place. I have yet to figure out how to mix and match groups of addressable assets. Its really sad that this thread hasn't been replied to in 2 years.
     
  13. LuGus-Jan

    LuGus-Jan

    Joined:
    Oct 3, 2016
    Posts:
    169
    @CCrowell

    I'm not sure if your client seeks the functionality of essentially 'traditional DLC', which was the topic of this thread and my original issue as well. But if it is, I can redirect you to a modified implementation of Addressables with some changes to support this exact functionality. You can find it here.

    Do note that it only supports offline bundles, i.e. it doesn't support content bundles that are supposed to be loaded remotely through Addressables. Only the 'local' build and load paths are supported. Content delivery is expected to be done by a different system, e.g. Steam.
     
    DREBOTgamestudio likes this.