Skip to content

AddMethodModule

UserR00T edited this page Aug 9, 2021 · 1 revision

AddMethodModule

This module is used to add a specific method to the target type. By decorating your method with the AddMethodAttribute you will allow UniversalUnityHooks to add your method. Very useful for reflection grabbed methods, like Unity's Enable, Update, and more.

Example

// Source (plugin)
[AddMethodAttribute(typeof(ExampleType))]
public static void Enable(ExampleType exampleType)
{
    Debug.Log($"Target type got enabled! {exampleType.name}"); // Console.log for non Unity applications.
}

// Target _after_ injecting (Assembly-CSharp.dll)
public class ExampleType
{
    // This method has just been added by UniversalUnityHooks. References and using declarations will be automatically handled.
    public void Enable()
    {
        MyPluginType.Enable(this);
    }
}

Attribute arguments

Name Description Default
Type
Method
Flags
StartCode
Token
Direction
Clone this wiki locally