Git Product home page Git Product logo

Comments (8)

grossbacher avatar grossbacher commented on August 11, 2024 1

Nevermind, I figured it out! The code doesn't work, but I know how to do it!

from harmonyx.

ManlyMarco avatar ManlyMarco commented on August 11, 2024

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.

grossbacher avatar grossbacher commented on August 11, 2024

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.

grossbacher avatar grossbacher commented on August 11, 2024

Original code for reference: MethodInfo dynMethod = this.GetType().GetMethod("Draw_" + itemType, BindingFlags.NonPublic | BindingFlags.Instance); dynMethod.Invoke(this, new object[] { methodParams });

from harmonyx.

grossbacher avatar grossbacher commented on August 11, 2024

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.

PhantomGamers avatar PhantomGamers commented on August 11, 2024

this would be __instance

see https://github.com/BepInEx/HarmonyX/wiki/Patch-parameters

from harmonyx.

grossbacher avatar grossbacher commented on August 11, 2024

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.

grossbacher avatar grossbacher commented on August 11, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.