Search Unity

Question Code as a deployable in an AssetBundle?

Discussion in 'Addressables' started by KingKRoecks, Oct 26, 2022.

  1. KingKRoecks

    KingKRoecks

    Joined:
    Jul 28, 2013
    Posts:
    155
    My team has been working towards a series of milestones that have, of course, introduced tech debt.
    We're currently evaluating re-writing some systems, but how we approach that is going to be based on what we can get away with.

    As the topic suggests, I want to know:
    "Can you deploy code with an asset bundle?"

    I totally get that this question sounds disgusting. If you feel that way, pat yourself on the back, because it's a correct reaction here lol. But we're here to push boundaries!... or something.

    So can we push down a DLL with the asset bundle including how the code should do things?
    Is there any other approach to it?


    Anyway, if anyone knows if there's an approach to deploying code with a given asset bundle, I would love to know! Thanks!
     
  2. BerkayDursun

    BerkayDursun

    Joined:
    Jan 11, 2021
    Posts:
    1
    Technically you can download a DLL and bind it to application with some dynamic loading. The real question is not if you could but if you should. Because If your application tries to load a compiled library in runtime, then there will be some serious security breach. Anyone can stick their own code to your application and do anything malicious with it. It's not only about hacking or cheating your game, the device will be compromised too. The OS will prevent anything serious damage but you could never know. Of course you can implement your own security layer, but If you are asking this question here, If won't be a viable approach for you.

    What you should rather do is maybe develop your application in such a modular fashion that every feature is compiled from pre-built smaller code pieces. Think of it like the Unreal's blueprint system. In visual scripting system, the code blocks are already exissts in the application. The only thing you manage is how you put these blocks together. That essentially defines a configuration, or a "blueprint" per se.

    What you can do now is you can send the "blueprint data" via Addressables. You don't inject any code in runtime. You just fetch the data of how to reference some already existed codeblocks in your application.
     
    Last edited: Nov 9, 2022