ManlyMarco / RuntimeUnityEditor

In-game inspector and debugging tools for applications made with Unity3D game engine
GNU General Public License v3.0
810 stars 99 forks source link

Support for Unity Mod Manager #39

Closed mricher-git closed 1 year ago

mricher-git commented 1 year ago

Hi, I have forked the project and added support for UnityModManager, using RuntimeUnityEditor.Bepin5 as a reference and created a RuntimeUnityEditor.UMM project with the solution.

Would you be willing to accept a PR and officially add UMM support for this project?

ManlyMarco commented 1 year ago

Hello! Yes I'd love to add support for more mod loaders, that's the reason why I structured RUE as it is.

mricher-git commented 1 year ago

Great to hear. Getting it up and running was pretty straight forward, the hold up at the moment is dealing with the settings in a manageable way.

BIE uses dynamic config through Config.Bind methodology, whereas UMM expects mods to derive from a ModSettings class, add all respective settings to that class, and then it takes care of serializing to/from Settings.xml. It also has something similiar to Configuration Manager baked in, and displays a config GUI based on field type.

Adhering to the RegisterSetting methodology is becoming a bit of a bear, effectively needs almost a standalone implementation of BepInEx's ConfigEntry(Base) class in lieu of ModSettings, manual serialization and converting UnityEngine.Rect to something XmlSerializer supports (like you did for Toml) and then a lightweight implementation of Config Mgr for dynamically drawing the UI based on field type. Anyway, almost there. I'll push it shortly to my fork and you can perhaps poke your head in there, give it a look over, see if there are glaring changes you would like to see.

ManlyMarco commented 1 year ago

You could maybe still make a custom ModSettings class but harmony patch it to override whatever code requires properties to instead use a list. I'd imagine it would make things a lot simpler.

There will definitely be more settings added in the future so it's not practical to specify all of them now.

mricher-git commented 1 year ago

Was a genius idea, 3 hours down the rabbit hole later, it was much easier just to reimplement. Here's a link to the function I was going to hook for laughs https://github.com/newman55/unity-mod-manager/blob/934022da3b002f629f0065a6a9a952071965e105/UnityModManager/UIDraw.cs#L632

Anyway, it's pretty much ready, going to look it over for refactoring, etc, but it's 100% functional. Just waiting for latest NuGet for UMM.dll to get pushed up as he made some changes for me.

https://github.com/mricher-git/RuntimeUnityEditor/tree/feat-umm-support

Do you have any UMM based games to test it out? https://github.com/mricher-git/RuntimeUnityEditor/releases/tag/v4.2.0.0-alpha

ManlyMarco commented 1 year ago

I looked through the changes so far and they seem good to me. I'll be looking forward to the PR.

Do you have any UMM based games to test it out?

I don't actually, I tend to use BepInEx for everything. I'll try it out once you're finished with the PR.

mricher-git commented 1 year ago

Only thing left to do is the dependencies. BepInEx ships with Mono.Cecil and MonoMod.Utils/RuntimeDetour, UMM does not. Could either add these as dependencies to RuntimeUnityEditor.UMM with copy local and they'll get picked up by release.ps1, or keep them as dependencies only on core, enable copy local within core, and modify release.ps1 so RUE.BepInEx doesn't pull them in.

I also see install.ps1 turns copy local off for everything, so both of the above options would require a further change here too. Thoughts?

ManlyMarco commented 1 year ago

Add it to RuntimeUnityEditor.UMM. The version doesn't have to be exact so you could use a package from a different source that doesn't have the copylocal script. Maybe some other UMM plugins already use it, in which case it would be best to use that version.

mricher-git commented 1 year ago

Not sure if there is notification on comments after pull, so just in case you missed this: https://github.com/ManlyMarco/RuntimeUnityEditor/pull/40#issuecomment-1646233668

ManlyMarco commented 1 year ago

@mricher-git Released.

mricher-git commented 1 year ago

@ManlyMarco have you seen https://github.com/ManlyMarco/RuntimeUnityEditor/pull/40#issuecomment-1646233668 ? I can make a PR for it if you want to go ahead.

ManlyMarco commented 1 year ago

@mricher-git Sorry, I didn't see it. Can you make a PR? You can place the file inside https://github.com/ManlyMarco/RuntimeUnityEditor/tree/master/RuntimeUnityEditor.UMM Is there any way to make this file auto update on release? There's no way I'll remember to do it. Maybe a GitHub action?