Loading modded assemblies with same class name

Hey guys.

I recently started thinking about how to add modding support for my game. For that, I want users to be able to download a modkit for Unity, create their mod in Unity, and then export it. So far so good.

Now, let’s say the modkit has a script and class called “Entity”, that modded scripts can inherit from, which implements some methods for entity control.

In my compiled game, there will already be an assembly that has “Entity” defined somewhere, which would lead to conflicts. How would I go about correctly loading that assembly? Would the classes and methods need to be partial on both sides?

I’ve never added a mod to a game before. I’ve seen some examples in the past but they’re normally just data related like this tutorial. There is also Unity User-Generated Content (UGC) but I think that’s more related to managing content. https://youtu.be/O9LevbWQj28

If I wanted to have different logic then I’d probably try behavior graphs as they’re just data. Or maybe a scripting language like lua. I used MoonSharp a long time ago, not sure what options lua has nowadays. You’ll find that c# dlls have to many security issues for users. A few Unity mods I’ve seen are done by advanced modders have directly modify the game. If I did plan on allowing a dll mod I might just make interfaces and have a text file for dependency injection. So the names or namespaces don’t need to match, it just needs to implement the interface. You might also find that directly loading a dll will only work on some platforms like Windows.