BepInEx plugin loaded, but HarmonyPatch annotation have no effect #483
-
This is my first time using BepInEx. I created my project with command line: I've gone through troubleshooting page and did all I can, I wrote another plugin for game Smelter just for test, same problem. I can confirm I'm not patching wrong method, because I tested by modify the same method in Assembly-CSharp.dll with dnspy. Console Log: [Message: BepInEx] BepInEx 5.4.21.0 - MetalUnit (2021/1/28 10:40:42) The original method looks like this: public void OnDiscordClick() My plugin code is very simple, as below. I'm patching menu button function because it's easy to test. using BepInEx; namespace MetalUnitCheatPlugin
} None of the logs recorded my message, and the original method is still executed. So I guess the prefix is not called. I've no idea what's wrong, and no direction of determin the cause of problem. Please help. Update1: I looked into some plugins written by others, one of them calls "new Harmony()" in Awake(). I added similar code in my plugin, and the patch worked! new Harmony("MetalUnitCheatPlugin").Patch(AccessTools.Method(typeof(TitleMenuController), nameof(TitleMenuController.OnDiscordClick), null, null), new HarmonyMethod(AccessTools.Method(typeof(Plugin), nameof(Plugin.OnDiscordClickPrefix), null, null)), null, null, null, null); It seems the problem is [HarmonyPatch(typeof(TitleMenuController), nameof(TitleMenuController.OnDiscordClick)/"OnDiscordClick"/)] annotation have no effect. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Please ignore this question. |
Beta Was this translation helpful? Give feedback.
Please ignore this question.
I've figured out I need another class for annotations.