top of page


namespace - XGI.Tools

This class enables the user to treat methods like properties i.e. pass them as arguments, copy them, use them as return variable from other methods etc. MethodHandler is much more flexible and mobile as compared to Delegates or Actions.

How to Initialize a method handler -

public SampleClass


    private void OnEnable()


        MethodHandler demoHandler = new MethodHandler(typeof(NewBehaviourScript).GetMethod("TestMethod"), this, new object[]{})


    public string TestMethod() => "Test Method Invoked";


Now demoHandler can be passed arround like any other variable.

How to Invoke a method stored using MethodHandler -

string handlerReturnValue = demoHandler.Execute();

Or simply



If no value is to be returned.

Constructor -

  • MethodHandler(MethodInfo methodInformation, object instance, object[] arguments)

Methods -

  • Type GetReturnType() => Returns the return type of the stored method

  • object Execute() => Executes the stored method

bottom of page