Change the code.
Keep the original.
Run your code before, after, or inside existing methods. Combine patches from multiple authors without changing files on disk.
[HarmonyPatch(typeof(Player), "GetSpeed")]
static class SpeedPatch
{
static void Postfix(ref float __result)
{
__result *= 1.5f;
}
}
See how postfixes work
You're reading the Harmony 3 preview. For the current stable version, use the 2.x documentation.
Find your way in
Your first patch
Install Harmony, pick a method, and apply a patch. Start with a complete working example.
Follow the exampleMeet Infix
Target an operation inside a method using familiar patch types. New in v3.
Explore InfixAPI reference
Find types, signatures, parameters, and overloads generated directly from Harmony.
Browse the APIHow a patch fits together
- PrefixRead arguments, change them, or skip the original.
- OriginalRun the method body, including any instruction edits.
- PostfixRead or change the result after completion or a skip.
A prefix can skip the original; postfixes still run. An exception interrupts the sequence and skips remaining postfixes. A finalizer can observe, change, or suppress that exception.
Built for patches that coexist
Harmony combines patches on the same method and lets their authors coordinate execution order. It supports .NET and Mono environments, including many Unity games. Runtime capabilities still matter: see the limits of runtime patching.
Get Harmony into your project
Use Lib.Harmony for one DLL with its dependencies merged in. Use Lib.Harmony.Thin when you want to manage those dependencies yourself.
This site describes v3 preview development on the v3 branch. Check the version your application loads before using new APIs. The installation guide covers the steps.
Made for the modding community
Andreas Pardeike created Harmony for RimWorld and its modding community. Today it is used in many games and applications.
Discuss patches on Discord, report a problem on GitHub, or contribute an improvement to the guides.
Contact Andreas at [email protected]. Support Harmony on Patreon.