🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Supporting mods in Unity game?

Started by
2 comments, last by Shaarigan 5 years, 8 months ago

Hi everyone,

Is there a way to allow mods, adding assets and code, to a Windows/Linux/MacOS Unity based game? We've tried googling for a bit and haven't really had much success. We are developing an RTS game with a large focus on resource management and production chains. We feel like the game design and logic engine are very well suited for mods and extending the amount of buildings, goods, research technologies and units, but we've had some trouble figuring out how to support this. Is it possible at all to begin with? Are there licensing aspects to deal with as well?

Advertisement

For code:  As long as you aren't using IL2CPP, you can dynamically load new C# DLLs (as long as you trust modders to not do malicious things in these DLLs).  You can also use any other scripting language that works with C#, possibly even if you're using IL2CPP, as long as that language doesn't use any runtime code generation.

For assets:  You can load AssetBundles as long as they are compatible (any MonoBehaviours they use have to come from the assemblies your game shipped with) - this is how we do DLC where I work.  You also have limited support to load "raw" assets and files (text files, typical File I/O, png files, etc).  You can also programmatically construct several types of assets (images, meshes) at runtime, so you could write your own 3D model loading code if you wanted to spend the time doing that.

In one of my old games we stored our maps outside of unity to edit and rapidly add new content. Those were decoupled to the raw map data used in Unity Terrain as same as some description files where to place what kind of entity including direction, size and whatever was neccessary.

For code you can provide some kind of scripting language yourself or use some known parser/lexer for existing languages as long as there isn't any compiler magic or native assembly magic in there. This way you can control where to allow code and where to keep your static game code safe from modifications. You can then take the OpCode-ed script files and either run an interpreter written in managed code or compile those OpCodes to IL using System.Reflection.Emit, even when driving with IL2CPP

This topic is closed to new replies.

Advertisement