
[Enhancement]: Hot reload for Mono mods
DomNomNomVR opened this issue ยท 7 comments
Describe the new feature or enhancement
I'm putting a bounty of $100 USD on this feature which would allow me to reload a mod I'm working on in a game like ChilloutVR without needing to restart the game.
As tempting as $100 would be, This is way out of scope for MelonLoader. The way Unity reloads assemblies in the editor requires a full AppDomain reload, which is just a big "nope" for us. we partially support hot-reloading of code on il2cpp games, by attaching visual studio as a debugger. That's sadly as far as we can go.
You could probably do something similar to ScriptEngine for BepInEx, its not full hot-reload, but you can destroy the existing plugin behavior and load the new assembly in its place to get something very similar. https://github.com/BepInEx/BepInEx.Debug/blob/master/src/ScriptEngine/ScriptEngine.cs
Very well, i will open this back up for discussion and see if we can sort of implement this
Mono doesn't have hot reloading as a feature, and otherwise you'd have to reload the entire domain, which comes with its own issues.
I suggest dismissing this issue. It's a nice idea, but it's kinda unrealistic
Mono doesn't have hot reloading as a feature, and otherwise you'd have to reload the entire domain, which comes with its own issues. I suggest dismissing this issue. It's a nice idea, but it's kinda unrealistic
The idea was to have Mods faux reload and just reattach the new assembly.
Even if it doesn't actually unload the assembly at least the new one would load and run.
This also comes with its own issues.
First, you'd have to make sure that there are 100% no references to the old assembly. This includes delegate refs, object refs, etc.
Next, you'd have to transfer all static field values from the old assembly to the new one, which would also mean recreating some objects from scratch, basically converting objects of older classes to the newer ones. Think of it as serializing the previous assembly data and deserializing it into the new one.
And then you also need to consider, how are you going to deal with conflicts? If a single static field is renamed and the old assembly held data in it, what are you gonna do?
There is a LOT to consider when doing such operations