Modding And ECS

I’m currently working on a game which we’d like to support modding.

With standard gameobjects I think this would be pretty simple. Modders can create a new visual studio project, add a reference to UnityEngine.dll, import a DLL defining certain game interfaces and that’s all they need to do. The DLL VS produces can be loaded up by the game at runtime and we can reflect things out and create them.

How would this work with ECS? I can see a number of problems:

  • ECS isn’t a DLL that can be referenced, how would modders write ECS compatible code? [1]
  • Can we use burst to produce a DLL that the game can load/reflect?
  • Can modders write code for the job system, is that a DLL that can be added as a reference?

[1] How to create a library (DLL) that references Unity.Entities?

ECS generates a dll when building a player. Its using asmdef to build the C# files into a dll.

1 Like

So I could gives modders a template Unity project just containing the game interfaces (but not the game itself) and then they could grab the DLL that compiles, drop it into my game folder and I can load it up/reflect it as normal? If so that’s great.

How does this interact with burst - can I load and reflect burst compiled DLLs in the same way as a standard C# compiled DLL?

1 Like

Burst is basically just extracting .NET IL from the original source, and makes a fast path available to the C# job system. So the original source is unmodified in .NET. dll.s

1 Like

So is my understanding is correct, if some modder decide to drop in his dll, with matching ECS Components and namesapce, lets say including Position component in JobSystem, with some new behavior, would it mean, it can override, or even duplicate position mechanics?

So for instance, if I have two system moving position +1 in x direction, this will result in total +2. Is that so? Or is more into it? For modding purposes, that could be great.
Otherwise, need some form of protecting relevant systems and/or components from being override by dlls.

"So for instance, if I have two system moving position +1 in x direction, this will result in total +2. Is that so? Or is more into it? For modding purposes, that could be great. "

Correct. I would expect it to be quite straightforward to inject modded system into an existing game. The ECS architecture should make modding overall quite a bit easier.

3 Likes