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. Dismiss Notice

Question Creating a modding project for players with DLLs instead of source code?

Discussion in 'Scripting' started by SamKennedy, Jun 29, 2023.

  1. SamKennedy

    SamKennedy

    Joined:
    Apr 25, 2021
    Posts:
    12
    I have set up my game to load a vehicle from an asset bundle. I have a set of scripts that load the vehicle from the bundle, then sets all the required references on monobehaviours before enabling the scripts on the vehicle so that it works with other scripts inside the main project.

    Loading the vehicle from the asset bundle is working fine, now I'm at the stage where I want to provide my players with a template project so that they can create their own vehicles, compile their own asset bundles and load them in the game.

    The challenge I'm having is that I would like to reference compiled scripts rather than providing users with my own source code. I have spent a large amount of time separating the components of the game into different DLLs using assembly definitions and references, so I have DLLs both in the Library/ScriptAssemblies directory, as well as the "build" directory for the game.

    I know I can drag-and-drop DLLs into the template project, however I want to reference either the DLLs in the ScriptAssemblies directory or the full build. If I place the DLLs in the template project, the references break when loaded into the main project since the main project uses the compiled DLLs and not DLLs that have been added in the editor.

    Any suggestions on how I could go about providing a template project using my custom DLLs would be hugely appreciated (by both myself and players eager to mod the game!)
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    You mean a Unity project? You want modders to use Unity to create mods for your game? This will add a significant learning curve to the uninitiated modder, let alone a 4+ GB download and install. And with Unity they could put anything in the asset bundle and they will find ways to exploit that, possibly running any code on the user's system through your game.

    You should check the asset store or blogs on how to add modding functionality to a game. Typically you do not want users to program code but rather give them a virtual machine, typically a scripting language, within which they can do whatever they can but due to the restricted nature of the scripts they won't be able to do (much) harm.