UnityExplorer
UnityExplorer copied to clipboard
[Bug]: Doesn't work with latest Harmony
Are you on the latest version of UnityExplorer?
- [X] Yes, I'm on the latest version of UnityExplorer.
Which release are you using?
Standalone Mono
Which game did this occur on?
Plasma / Unity 2021.1.281
Describe the issue.
See error below. UnityExplorer only works if I use the specific version of Harmony packaged with it. It does not seem compatible with the latest version as published or built from source.
I can replace Harmony globally for the entire loader, but that is icky, and would affect other mods. Nonetheless, doing it allows UnityExplorer to load, so my setup is indeed not cursed:
Relevant log output
[UnityExplorer] [Exception] OnToggle: MissingMethodException - System.Reflection.MethodInfo HarmonyLib.Harmony.Patch(System.Reflection.MethodBase,HarmonyLib.HarmonyMethod,HarmonyLib.HarmonyMethod,HarmonyLib.HarmonyMethod,HarmonyLib.HarmonyMethod,HarmonyLib.HarmonyMethod)
System.MissingMethodException: System.Reflection.MethodInfo HarmonyLib.Harmony.Patch(System.Reflection.MethodBase,HarmonyLib.HarmonyMethod,HarmonyLib.HarmonyMethod,HarmonyLib.HarmonyMethod,HarmonyLib.HarmonyMethod,HarmonyLib.HarmonyMethod)
at UnityExplorer.Runtime.UnityCrashPrevention.Init () [0x00001] in <5e0aa91eab9c4d71af554120cc9459dc>:0
at UnityExplorer.ExplorerCore.Init (UnityExplorer.IExplorerLoader loader) [0x000c1] in <5e0aa91eab9c4d71af554120cc9459dc>:0
at UnityExplorer.ExplorerStandalone.Init () [0x00013] in <5e0aa91eab9c4d71af554120cc9459dc>:0
at UnityExplorer.ExplorerStandalone.CreateInstance (System.Action`2[T1,T2] logListener, System.String unhollowedModulesPath) [0x0001b] in <5e0aa91eab9c4d71af554120cc9459dc>:0
at UnityExplorer.ExplorerStandalone.CreateInstance () [0x00000] in <5e0aa91eab9c4d71af554120cc9459dc>:0
at UnityExplorer.Main.OnToggle (UnityModManagerNet.UnityModManager+ModEntry entry, System.Boolean active) [0x00010] in <fd0953ccaf8340a194e0e58a3c5ceccb>:0
at UnityModManagerNet.UnityModManager+ModEntry.set_Active (System.Boolean value) [0x0006a] in <ed510dbfd2164cfaa2793f70ef8091df>:0
It is likely the issue is that the Harmony version you are using is the original Harmony and not HarmonyX. UnityExplorer uses HarmonyX, which is a fork of Harmony.
It would be nice if there was a standalone version of UnityExplorer that used the original Harmony instead of HarmonyX as there are quite a few unity games that do ship with modding support and include the original Harmony.
It is likely the issue is that the Harmony version you are using is the original Harmony and not HarmonyX. UnityExplorer uses HarmonyX, which is a fork of Harmony.
Ah, that sounds like it would be it, then.
It would be nice if there was a standalone version of UnityExplorer that used the original Harmony instead of HarmonyX as there are quite a few unity games that do ship with modding support and include the original Harmony.
Absolutely.
Just ran into the same issue with a game where the "standard" Harmony is the original.
I concur that this is an unfortunate situation, but to be fair, I think the core of the issue here is on the HarmonyX fork, which by not defining a separate assembly / namespace is making impossible for it to coexist with the original.
I opened an issue about it on the HarmonyX repo : https://github.com/BepInEx/HarmonyX/issues/53 Unfortunately, given that this would be a backward compat breaking change, this is unlikely to happen anytime soon...
Realistically, there only two solutions :
- Make a fork of HarmonyX with a different assembly name and namespace so it can coexist with the original (there might be further technical gotchas to this...)
- Make a fork of UnityExplorer that use the original Harmony instead of HarmonyX. Not sure how difficult this is.