Search Unity

Using AssetBundles - Patching/ BugFixing/ DLC - Download from Sever, replace old

Discussion in 'Asset Bundles' started by IAAAI, Oct 17, 2018.

  1. IAAAI


    Oct 17, 2018
    Hello Community! :D
    Sry in advance for my english "work in progress" :p

    Pls, don't judge me "ahh...another AssetBundle thread".
    I know there are a lot but hear me out. (read me out?) - > An Answer is still not found.

    Question: I want to Patch/ Bug-Fix/ Add Content to a game after deploy. - keep download small
    • just update scripts for bug fixes (Not possible? - highly advanced?)
    • just update visual/graphfics for bug fixes
    • add content -> DLCs - new functionalitys (visuals, code/ gameplay)
    LOOKING away from AssetBundles for a solution:
    • Asset Store: P.A.T.C.H.
    • Asset Store: Coffe Auto Patcher Tool
    • Asset Store: Free Simple Patch Tool
    All not relying on AssetBundle but "just" comparing binary data and replacing with new ones.

    HOW far i got: Manual, Youtube, Unite
    - Assign/ Group Assets -> AssetBundle
    - Editor Script -> BuildPipeline
    - Manually upload AssetBundle-Folder to Sever
    - Managed to download Bundle and instantiate content from it.(UnityWebRequest, DownloadHandlerAss..)

    BUT I want to save the downloaded Bundles not download them each time.
    Want to replace Bundles on hard drive(game folder) with same name as old.

    I want to bug fix by replacing scripts (compiled?).

    How are thousends of Unity games doing such an important part. PATCHING, CONTENT UPDATING without to build entier game a new, uploading those GBs of data and customer downloading those GBs of data EACH time.

    I still have to look into a lot of stuff scatted around the globe. :(
    I am a beginner, so that is somehow a huge task to deal with so it seems.

    Does somebody have great examples?

    I hope to get some help, advice.

  2. M_R


    Apr 15, 2015
    1) scripts cannot be included in asset bundles.
    - they are not even included in the build, they are compiled into the executable
    -- you can manually load an assembly at runtime, but only on mono (no IL2CPP) and it may not be allowed on the stores (i.e. Apple rejects it)
    2) you can include everything else in bundles. to bug fix, you release a new executable without changing the bundles so they are not downloaded again.
    3) you can build a high-level system to handle "dlc gameplay code" without using actual scripts and script only the low-level blocks that you need. then create new gameplay by combining those blocks via data assets (look at ScriptableObject)
  3. IAAAI


    Oct 17, 2018
    Hi there! :)
    Ty for the fast reply.

    1) Using Mono - Dynamically loading at runtime: e.g. Assembly.LoadFrom...

    2)Yes including everything and loading from them.
    - bug-fixing through new executable? -> Means just upload the ".exe" and replace it do fix bugs in code?
    - would that not also apply for new gameplay scripts by just replacing old ".exe" :D

    But what about the saving of "downloaded" Bundles via UnityWebRequest and DownloadHandler?
    How do i save those files permenantly after downloading so they will be there after the next start of the game?
    e.g. replacing old bundle via download.

    3) would u like to define "low-level blocks" -> What if DLC as Monster with own special attacks via own script.
    I WILL definently look at ScriptableObjects.

    I hope for some more help. Ty in advance. :D
  4. M_R


    Apr 15, 2015
    1) then you can do it (assuming you are targetting desktop here). you can get a DLL file (or byte[] contents) and load that. define some interfaces/attributes in the core exe and load the types dynamically (e.g.
    var myFoo = (IFoo) Activator.CreateInstance(assembly.GetType("MyNamespace.CustomFoo"), ...);

    2) when you use
    , bundles are cached locally and it will not be downloaded if you specify the correct hash/version. idk on desktop, on mobile cache is persisted across app upgrades, as long as you don't uninstall/delete all data/clear cache from system settings.

    3) example: instead of a "Fireball" script, you have smaller, atomic behaviors like "Target", "Collision", "Damage", "Animation", etc... and compose your fireball exclusively through data (i.e. the inspector). the special attack of the monster is built by combining those existing scripts. you can use e.g. Timeline to orchestrate the attacks and spawn particles / other objects at defined time. you only need a generic "spawn" script in your code. of course you need to plan what could be extended beforehand.
  5. IAAAI


    Oct 17, 2018
    That was a quick reply! :eek:
    Ty! :)

    1) I will take a look at that. Maybe u allrdy know where i find great example projects. ;)

    2) cached locally -> specify correct hash/ version o_O - If i download a Bundle with the same name AS the Bundle in the local folders it will use the newer one automatically? And another UnityWebRequest for the same bundle will do nothing cause there is allrdy the same bundle allrdy in the cache? :eek:

    3) That eyeopener :) - But it sound difficult. That will take some time until i handle atomic behaviors. I AM FIRED UP ;)
  6. M_R


    Apr 15, 2015
    1) nothing great unfortunately, but you can google "plugin pattern" and find something (it's more related to modding though). you need to completely define and separate your interfaces

    - "plugin sdk" dll: contains
    interfaces, and
    attribute (attribute target = assembly).
    -- IPlugin has at least an
    Initialize(IApp app)
    method, which gets called on load
    - "your plugin" dll (dlc): contains
    class MyDLC : IPlugin {}
    implementing your plugin, and declare
    [assembly: PluginEntryPoint(typeof(MyDLC))]
    - "your game" exe: contains
    class App : IApp {}
    that provides means to interop.
    -- you can load plugin by fetching all PluginEntryPointAttribute and instantiating their specified type (casted as IPlugin) then call Initialize(yourAppInstance)
    --- then the plugin can register to what it needs from the app as callbacks
    you can give away the plugin sdk dll for others to create their own mods if you want

    2) you should not include bundles in the local folders. player will just download them the first time. this will keep the main build small, and you will update bugfixes to the code by releasing a new build

    3) just plan it carefully. the more generic your scripts are, the more they can be recycled. you can look at ECS, even if you will not using it directly you can learn about Data Driven Design and better separation of data from code
  7. IAAAI


    Oct 17, 2018
    Sry for not replying faster. I was busy -> got hold of AssetBundles and started documenting my thoughts and other privat stuff to do. :p Sry for that.

    Back to Topic:

    1) Google "plugin pattern" -> Modding and ur example: Will keep that in my mind! :D

    2) u know the biggest mistake was not to understand "UnityWebRequest.GetAssetBundle" and "DownloadHandlerAssetBundle". I was allways wondering why they were not saving/ caching downloaded stuff on local disk...Than i stumbled across "Best Practices -Guide" and the sentence "depending on how u config them"...o_O:rolleyes::eek:
    A sentence which SHOULD HAVE been in the Manual in detail... This means...

    Giving them 2 parameters ( URL, numberForCheck) ==== temporary caching and deleting after App close :confused::mad:

    Giving them 3 parameters ( URL, versionNumber, numberForCheck ===== stored using "caching system":eek::):D

    versionNumber can be anything...just change it manually or automatically (see patching in manual) so it "re-downloads" the AssetBundle with the same name again.

    numberForCheck can u turn of by inserting 0.

    SO MY BIG LESSON: To use AssetBundles can be simple if the Manual would clarify things a bit more before letting people go through ADVANCED stuff...:( so allways look at the scripting API for important information.:cool:

    3) Thanks for this important information of yours. ECS is a bit to advanced for know and still in full development. But i know that this will be important for the future. ;)

    Thanks overall for your help! I appriciate it. (But i guess not my spelling. Sry for that. :oops:)
    Last edited: Oct 21, 2018
  8. zainnn


    May 6, 2019
    Hi @Adrian_AABeginner ! I am visiting here after couple of months and i hope by now you have already found your solution.
    The only part which brought this thread to my attention is:
    "Question: I want to Patch/ Bug-Fix/ Add Content to a game after deploy. - keep download small
    • just update scripts for bug fixes (Not possible? - highly advanced?)
    • just update visual/graphfics for bug fixes
    • add content -> DLCs - new functionalitys (visuals, code/ gameplay)"
    So i am looking particularly on scripting area. So far we have been able to use asset bundles to incrementally patch the assets within the game without having to reinstall the game. But when it comes to the script i simply haven't gotten anywhere. So i was wondering have you found any solutions to it? It will be greatly helpful.
  9. aka3eka


    May 10, 2019
    I wonder too.
  10. IAAAI


    Oct 17, 2018
    Hi and ups!

    i forgot to answer...
    Apperantly people make use of e.g. STEAMs ability to handle it and other "Clients" like STEAM.
    To handle Patching in Unity itself i guess taking a look into the assetstore may help.
    Otherwise other third party tools. :D

    zainnn likes this.