Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement]: Hot reload for Mono mods #438

Open
DomNomNomVR opened this issue Apr 17, 2023 · 7 comments
Open

[Enhancement]: Hot reload for Mono mods #438

DomNomNomVR opened this issue Apr 17, 2023 · 7 comments
Labels
Improvement New feature or request Suggestion Work-in-Progress This issue or pull request is being worked on currently

Comments

@DomNomNomVR
Copy link

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.

@RinLovesYou
Copy link
Member

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.

@Windows10CE
Copy link
Contributor

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

@RinLovesYou
Copy link
Member

Very well, i will open this back up for discussion and see if we can sort of implement this

@RinLovesYou RinLovesYou reopened this Apr 18, 2023
@DomNomNomVR
Copy link
Author

Yes, partial reload would still be helpful.

@rakosi2 rakosi2 added Improvement New feature or request Suggestion labels Sep 13, 2023
@github-actions github-actions bot added the Stale label Oct 7, 2024
@rakosi2 rakosi2 removed the Stale label Oct 8, 2024
@LavaGang LavaGang deleted a comment from github-actions bot Oct 8, 2024
@HerpDerpinstine HerpDerpinstine added the Work-in-Progress This issue or pull request is being worked on currently label Oct 14, 2024
@slxdy
Copy link
Contributor

slxdy commented Jan 22, 2025

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

@HerpDerpinstine
Copy link
Member

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.

@slxdy
Copy link
Contributor

slxdy commented Jan 22, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement New feature or request Suggestion Work-in-Progress This issue or pull request is being worked on currently
Projects
None yet
Development

No branches or pull requests

6 participants