Comments (8)
Nevermind, I figured it out! The code doesn't work, but I know how to do it!
from harmonyx.
This is a general C# question, not a Harmony/BepInEx question. See https://learn.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/reflection and https://stackoverflow.com/questions/135443/how-do-i-use-reflection-to-invoke-a-private-method
Official BepInEx readme is at https://docs.bepinex.dev
from harmonyx.
I saw this when I 1st looked the problem up, have absolutely NO idea how to use it. What would I most likely replace this
with? Would it be the script name I patched? (Example: [HarmonyPatch(typeof(Revolver), "Update")]
(Putting Revolver instead of THIS is my best guess, but doesn't work) This is probably very important to learn, do you know?
from harmonyx.
Original code for reference: MethodInfo dynMethod = this.GetType().GetMethod("Draw_" + itemType, BindingFlags.NonPublic | BindingFlags.Instance); dynMethod.Invoke(this, new object[] { methodParams });
from harmonyx.
I probably should have mentioned: The function is inside of the Revolver script where I'm patching Update.
Normally, when I make games with unity, you can call private functions as long as they're defined in the same script they're called in. I read through the reflection help guide, and everyone's saying to avoid reflections at all costs. It can't be this hard, right? Is there any other way, like editing the function to be public and hoping it doesn't break anything?
from harmonyx.
this
would be __instance
see https://github.com/BepInEx/HarmonyX/wiki/Patch-parameters
from harmonyx.
I'll ask the lethal company discord, they're always helpful, but this puts me a step in the right direction! Thank you!
from harmonyx.
this
would be__instance
see https://github.com/BepInEx/HarmonyX/wiki/Patch-parameters
Wait actually I have another question. How would I get ___Instance? Do I have to ref Script ___instance or is it automatic?
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 2
- 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 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 5
- 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.