Modding and IL2CPP

Maybe I’m running ahead of time by planning modding support (for PC game).

But I wonder, is it better to use Mono instead of IL2CPP if I’d want to implement dynamic library linking?
E.g. loading external libraries in runtime and merging functionality / method calls in runtime?

I don’t want to go lua path or providing separate language assets.
Full code access is better for the modding community (I think?). What do you guys think?

I’m not too C++ savy, so maybe someone can provide some info on the topic?

With IL2CPP, all of the managed code that will be used in the game must be present at compile time. It is not currently possible to use IL2CPP to load an assembly that was compiled separately.

So, if you intend to support modding, I would recommend using the Mono scripting backend.

5 Likes

Definitely use Mono, I’ve wanted to mod Pistol Whip for a while now, but they build in IL2CPP, and its a much more complex process than Injected Mono modding with harmony or IPA.

1 Like

I too am looking into this, I would love some way to compile C# to il2cpp but it looks like a very complex process so mono for modding seems the best way.

I haven’t tried yet but I think the .net roslyn packages should work with unity which you could use to allow modders to provide .cs files which you load and execute (can be unsafe)

Another option is to implement some sort of scripting language (Lua?) and use that

I did some modding for Witcher 3 recently, and I like how they supplied full source .ws scripts plus compiler for them.
So the game checks if the sources / mod files are changed and recompiles them at launch + outputs errors in the console alike window.

Made modding really easy, but the source itself is a bit… overwhelmingly ugly.
Or maybe its because I did it via Notepad++ :smile: