pardeike / Harmony

A library for patching, replacing and decorating .NET and Mono methods during runtime
https://www.patreon.com/pardeike
MIT License
5.24k stars 492 forks source link

Getting an instance from the TargetMethod patch #568

Closed cry-1337 closed 8 months ago

cry-1337 commented 8 months ago

I have internal class Glazier_uGUI. I need to patch method UpdateCursor to do custom in-game cursor. I wrote code for this but i have no idea how to get instance of it.

static MethodBase TargetMethod()
{
     var type = AccessTools.TypeByName("Glazier_uGUI");
     return AccessTools.Method(type, "UpdateCursor");
}

private static bool Prefix()
{
      return false;
}
pardeike commented 8 months ago

Have you checked out the documentation? You simply inject the instance into your patch. Issue tracking is not for support questions so please use the official discord.