- Home /
mods to unity kinda?
hi im making a minecraft clone! i know that java is easy to mod but i never seen unity so im looking to integrate mods to my game and i thinked ill make a folder in my Game_Data folder called mods and modders will write the javascript in text files in the folder so can someone give me a hand? oh and if you say like (an example (not gonna work)) PlayerPrefs so you will link the source/ tutorial/wiki page/etc. EDIT: To all who didn't understand, I CREATE A MINECRAFT STYLE GAME IN UNITYSCRIPT NOT A MINECRAFT MOD!
Is there a $$anonymous$$ecraft come-back I don't know about? Quite a few people are using unity to make $$anonymous$$ecraft style games. That aside what is the question?
$$anonymous$$ake sure you don't confuse Java with Javascript - they're very different things. Are you trying to just mod $$anonymous$$inecraft itself or are you going to build it from scratch?
Answer by Peter G · Apr 21, 2011 at 10:19 PM
It will be difficult to include mods in Unity. Unity won't compile code that your users add into a folder so it isn't as simple as just letting them place scripts in a folder.
You can load assemblies into Unity using Reflection. I don't have an example, but I don't know why you couldn't do it.
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx
Answer by justlost · Feb 15, 2012 at 07:03 AM
Adding to what Peter G said, the only way you are going to be able to allow mods is if you load dlls dynamically from your game.
I've gotten this to work on unity indie and there is no reason it wouldn't work on pro.
Tho, you have to do some preparation. You'll need an assembly(a dll) that both the mod and your game share. This assembly should expose either Interfaces or Classes that the mods can inherit/extend. Be careful tho, only expose interfaces/classes you want the mods to use. Also, changing that shared dll in any way after your game is ship would probably break mods unless you take some precautions.
One more caveat to this method is that once you load the dll, it can not be unloaded while the game is running, so you have to take that in consideration.
The other potential big issue is that you will probably only be able to take dlls made from visual studio/mono as I haven't seen the unity editor compile libraries. But that comes with the plus... just about any language that can compile to a .net(2.0 or 2.5) dll you can load as a mod.
Also, your modders will have to compile their mod libs to target .net 2.0 or 2.5 as that' s what unity is running on.
Answer by burgunfaust · Apr 21, 2011 at 10:24 PM
You could also load plain text files rather than java in text form. Those text files can be loaded at runtime, and therefore allow you mod a game.
Your answer
![](https://koobas.hobune.stream/wayback/20220613124339im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Pause Menu Background 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Help with placing and destroying blocks 1 Answer
Help with a Cubeland-type script. 1 Answer
How to make a Cube with a texture in a JavaScript? 0 Answers