Theoretically, how possible would it be to compile unity scripts into .dll’s and then send them from a server to a client at runtime? The idea behind this would be to allow for a multiplayer game with full scripting freedom, kind of like how a web browser works. The scripts would obviously be vetted in some way before being allowed online, so anything on the server would be trustworthy. How would someone make sure that a .dll wasn’t man in the middle attacked and replaced with another? Is there a way to restrict what a .dll can do? Possibly make it so it can only call a whitelist of functions?
I can foresee people telling me why this is a bad idea, so let me pre-answer those by saying I’m going to try to do it anyway, smart or not.
if there is a better option then a .dll for sending scripts over the network I’d love to hear it. I just hope it doesn’t come down to a custom scripting language.
Ok everyone is saying to just send the raw code and then compile it on the client side. But what if I want to keep that code secure and not just send the source code to everyone. Also I’m concerned about the performance of compiling code in the background constantly. (For my use case it will basically be constant/very often)
What do you mean by keeping the code “secure”? Your code can be and will be decompiled sooner or later. You can make it harder to be decompiled, see this Wikipedia page.
By secure I just mean that I don’t want to send something that sk
Basically I don’t want to send a c# string that a person could copy and paste easily. This is why I think a .dll if done in a way safe from hacking would be a good solution. The code would be about as hard to decompile as any other unity code, along with the added benefit of the client not needing to compile it on their end.
u can actually make a script that will: send a string data instead of the file and when it reachs the client another script needs to create a empty file and enter the code into after that it needs torename file as .blahblah
I’d be really careful about sending c# files over the network and compiling them at runtime. You are basically opening a back door on our users machines to being hacked. Making sure that a c# script is not malicious is incredibly hard so running user created game modes would be really dangerous. I’d recommend to look into a scripting language interpreter like for instance MoonSharp instead: MoonSharp | Tools | Unity Asset Store