Comments (3)
One applied, patches are referenced by the ID of your harmony instance, not by the methods/types the patches came from. You can use the same patches in two different instances with different IDs, and allowing unpatching by type would not work well with this. If you need to allow external code to unpatch, then give your harmony instance a known ID that other code/plugins can use.
from harmonyx.
To add to what Marco noted, you generally can use any of harmony.Unpatch*
methods to unpatch specific harmony instances by their ID. If you need to unpatch specific types, a reasonable workaround is
// Creates an instance and calls PatchAll(Type) for the given class
var instance = Harmony.CreateAndPatchAll(typeof(SomePatchClass));
// Use the patches...
// In the end, unpatch the instance
instance.UnpatchSelf();
If you need to unpatch ALL instances from a given method, use Unpatch(MethodBase, HarmonyPatchType, string)
or Unpatch(MethodBase, MethodInfo)
If we were to add any more Unpatch*
overloads, they need to be clearly defined with all possible edge cases outlined. For example, does UnpatchAll(Type)
mean that it takes a patch type and uptaches all harmony instances that have at least one method patched from the type? Or is the type some target type and UnpatchAll
unpatches all methods that are patched in the type?
Do feel free to suggest new Unpatch*
overloads. However, they generally need to be thought through pretty well since even right now it's a bit of a mess with all the different overloads and their sometimes unclear behaviour. We already tried to fix some of it (for instance by adding a warning message every time someone calls UnpatchAll
because of its unintended side-effects). We can't, unfortunately, change too much to keep functionality the same with vanilla Harmony.
from harmonyx.
Ok, thanks! I've just rewritten what I'm doing to have a new harmony instance for each patch block I do, so that's a reasonable workaround.
(By the way, what I would have needed this for is a multiplayer mod - patch blocks for server/client cases, where they can be switched around)
from harmonyx.
Related Issues (20)
- [Wiki] Typos in section 1.4 HOT 1
- [Wiki] Error using the provided postfix in section 1.4 HOT 1
- When will v2.11.0 be published on NuGet? HOT 2
- Android IL2CPP Support HOT 1
- v2.11.0: patch with "ref string" on "static external" method produces garbage HOT 5
- Harmony doesn't work when path contains non-ANSI characters HOT 1
- How do I call a private function within a postpatch HOT 8
- How do I find the asset directory of stuff stored in a unity game? HOT 1
- Reverse patches appears to be broken
- Assembly.GetExecutingAssembly causing game to crash HOT 8
- System.Reflection.Emit.ILGeneration is not supported on this platform when using Transpilers. HOT 4
- HarmonyX 2.13 in 7dtd: Interface Default Implementations failing to patch with odd error.
- Empty Transpiler Causing Issues HOT 1
- How to override explicit interface methods? HOT 1
- When did it start to support net 7 or 8? HOT 1
- Cannot unpatch extern method patch
- Patching ref parameter with IL2Cpp results in invalid IL
- Usage with unity
- Empty Harmony Annotations Cause ArguementException: No Target Method Found HOT 2
- Skipping a patch when a method isnt found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from harmonyx.