Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How do i create "DLC" for a Desktop game, example for steam release

Discussion in 'Asset Bundles' started by Vaupell, Jun 15, 2020.

  1. Vaupell

    Vaupell

    Joined:
    Dec 2, 2013
    Posts:
    302
    I am struggling to find forums discussions, guides, howto's etc. even youtube is failing me when searching on creating a seperate DLC package for an existing game.

    My searching might be terrible, maybe i am using poorly phrased searches, but still lucking out.

    I did find out that the unity package manager, does only allow adding of content like graphics, audio, levels, prefabs, etc. But no code.
    the no code part, puzzles me.

    I imagine adding new functionally to a exiting game, and that includes new code.
    But that mean i need to patch the game, and then add the media in the DLC.

    I was hoping that using the namespace in my game, and have a "checker" that checks on load if DLC is availible then it loads in that. and the DLC would just use the same namespace and everything will be wonderfull. (ofcourse i would patch the main game to check for specific DLC)

    Does anyone have examples or guides?

    TLDR: Want to add DLC to existing game, but dont know how to load it in when it's availibe.
     
    ShokWayve likes this.
  2. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    Asset DLCs can be done by using asset bundles. Code DLC, however, is not really supported out of the box in Unity. You need to dynamically load DLLs at runtime, which AFAIK is not simple. Also, you won't be to do this on any IL2CPP platform (everything besides PC and maybe Android).

    In the industry it's common to use DLC only for assets, and add the code to support that DLC to the game via a patch. Some platforms don't even allow DLC that contains native executables.

    Even then, your game needs to know how to enumerate and load the DLC. If you never coded it for that, you'll need at least one patch that adds that capability. There's no way around it. A DLC, basically, is a folder that may or may not be available.

    Of course, usually non-Unity games do use some kind of scripting language so they do have some "code" in their DLC, but in Unity all your scripts get compiled into one giant native blob when you IL2CPP.

    If your game has a large need for modding or adding substantial high-level logic via DLC, you should look into implementing an interpreted scripting solution on top of C#. I know there's a plug-in out there for using Lua in Unity, and there are likely to be other languages you can use.
     
    wccrawford and Vaupell like this.
  3. Vaupell

    Vaupell

    Joined:
    Dec 2, 2013
    Posts:
    302
    Nice feedback thank you, i was trying to see how Cities Skylines did it, which also is Unity made.

    By observing that game i noticed when they release a new DLC, they also patch the main game.
    Which tells me the patch brings the coded content for the DLC and the actual DLC download is just the
    media content.

    Then i start to think, how to you control if the DLC is avilible on the computer,
    simply by checking if the media files (asset bundle) are present?
     
  4. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    On Steam there are APIs to check if specific DLC is installed. Same on consoles, where DLCs are treated as folders you "mount" before being able to access.

    So the easiest way is to have each DLC be a subfolder in a specific folder, containing the DLC's bundles and assorted files. This way you can have a system that you can test independently of any platform.
     
  5. mjonasz

    mjonasz

    Joined:
    Sep 7, 2017
    Posts:
    12
    I'm not sure how these Steam APIs work and I'm really stuck on this whole DLC thing. Creating the asset bundle through Unity is simple enough, but what do you need to do so that the game knows that a specific asset bundle has been installed and therefore allows the player to use the content? For example, if a certain mission is supposed to be activated if the player purchases an asset bundle, then what would be the code to tell Unity that the player did purchase this asset bundle and the mission can be SetActive?
     
  6. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    You need to implement your own server infrastructure for this kind of functionality.

    Ideally you would develop some purchasing mechanism (perhaps you can use mobile platforms in-app-purchases), and then use Unity's caching layer to see if the bundle(s) associated to that purchase are available locally https://docs.unity3d.com/ScriptReference/Caching.html

    If they are, start the level, if they're not, start the download. Managing assetundles/downloads/caching/dependencies is complex. You may want to look into Unity's Addressables system to somewhat simplify things, which is a serverless approach (sort of)
     
  7. mjonasz

    mjonasz

    Joined:
    Sep 7, 2017
    Posts:
    12
    The game is already on Steam so the purchasing mechanism is through Steam DLC. I followed the Steam video that shows how to upload the DLC and it works because I see the asset bundle files appear in the game directory. But I can't figure out how to tell the game that that DLC was purchased so the mission can be SetActive.
     
  8. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    Use the Steamworks.Net plugin and use the SteamApps.BIsDlcInstalled method to query if a DLC is installed.
     
    Vaupell likes this.
  9. mjonasz

    mjonasz

    Joined:
    Sep 7, 2017
    Posts:
    12
    Thanks for setting me in the right direction. Installed the plugin but I get an error message on one of the scripts that came with it - "RedistCopy". The error is in "using Steamworks" - "type or namespace 'steamworks' could not be identified..."
     
  10. ShokWayve

    ShokWayve

    Joined:
    Jan 16, 2013
    Posts:
    136
    So let’s say I have the new assets to add to my game like a new car and new clothes for an avatar. Let’s say I want to use them as DLC. So, in Unity I add the new code to my game that checks for the DLC and uses it.

    Now, how do I get it to Steam or say Nintendo (for the Switch)? Do I upload my total new code with the new assets? Is the DLC they purchase actually just an indicator that they can use the DLC that’s already in the code but not activated?

    Thanks
     
  11. dennispr33

    dennispr33

    Joined:
    Apr 6, 2021
    Posts:
    4

    As I get it, you just implement the whole DLC in your game. So, you compile your game with the clothing in it from the beginning on and just deactivate it. Then you add a system which checks if the DLC has been purchased and if, you just set active the clothes or whatever.

    Correct me if I'm wrong :)
     
    ShokWayve likes this.
  12. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    That's the easy way of implementing it. But you can also support for actual downloadable content in the form of additional files which are only downloaded if the person owns the DLC.

    However, you cannot add new scripts this way, only things like assets/scenes/prefabs. You need to program your game to support the extra content in advance(or via an update).

    These DLC assets must be packaged using asset bundles (or Addressables, which are a form of asset bundles).

    On Steam the DLC files are downloaded it the game's install folder. On consoles, each DLC shows up as a different "folder" you can read the files from.
     
  13. danosono

    danosono

    Joined:
    Jan 22, 2019
    Posts:
    45
    I appreciate this discussion.

    I have a game built for Windows and am currently preparing it for Steam.

    The game is free and I may add additional music playlists as paid DLC.

    Sounds like I can build all anticipated playlists and check to see if the player purchased before enabling.

    Works perfectly for me because I don't want to add large audio files to the base game but the code and GUI won't take up much space.
     
  14. danosono

    danosono

    Joined:
    Jan 22, 2019
    Posts:
    45